PandA-2024.02
custom_map.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
33 
45 #ifndef CUSTOM_MAP_HPP
46 #define CUSTOM_MAP_HPP
47 
49 #include "config_HAVE_UNORDERED.hpp"
50 
51 #include <map>
52 #include <unordered_map>
53 
54 template <class T, class U, class Hash = std::hash<T>, class Eq = std::equal_to<T>,
55  class Alloc = std::allocator<std::pair<const T, U>>>
56 using UnorderedMapStd = std::unordered_map<T, U, Hash, Eq, Alloc>;
57 
58 template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
59  typename _Alloc = std::allocator<std::pair<const _Key, _Tp>>>
60 using OrderedMapStd = std::map<_Key, _Tp, _Compare, _Alloc>;
61 
62 #if !defined(__clang__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 8)
63 #ifndef NO_ABSEIL_HASH
64 #define NO_ABSEIL_HASH 1
65 #endif
66 
67 #include <utility> // for pair
68 
69 template <class T, class U, class _Hash = std::hash<T>, class _Eq = std::equal_to<T>,
70  class _Alloc = std::allocator<std::pair<const T, U>>>
72 
73 template <class T, class U, class _Hash = std::hash<T>, class _Eq = std::equal_to<T>,
74  class _Alloc = std::allocator<std::pair<const T, U>>>
76 
77 template <class T, class U, class _Hash = std::hash<T>, class _Eq = std::equal_to<T>,
78  class _Alloc = std::allocator<std::pair<const T, U>>>
80 
81 template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
82  typename _Alloc = std::allocator<std::pair<const _Key, _Tp>>>
84 
85 #if HAVE_UNORDERED
86 template <typename T, typename U>
88 #else
89 template <typename T, typename U>
91 #endif
92 
93 #else
94 #ifndef NO_ABSEIL_HASH
95 #define NO_ABSEIL_HASH 0
96 #endif
97 
98 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
99 #pragma GCC diagnostic push
100 #pragma GCC diagnostic ignored "-Wsign-conversion"
101 #pragma GCC diagnostic ignored "-Wconversion"
102 #pragma GCC diagnostic ignored "-Wpedantic"
103 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
104 #pragma GCC diagnostic ignored "-Woverflow"
105 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
106 #pragma GCC diagnostic ignored "-Wstrict-overflow"
107 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8
108 #pragma GCC diagnostic ignored "-Wshadow"
109 #pragma GCC diagnostic ignored "-Wundef"
110 #pragma GCC diagnostic ignored "-Weffc++"
111 #ifndef __cpp_constexpr
112 #define __cpp_constexpr 200704
113 #endif
114 #endif
115 #else
116 #pragma GCC diagnostic warning "-Wsign-conversion"
117 #pragma GCC diagnostic warning "-Wconversion"
118 #pragma GCC diagnostic warning "-Wpedantic"
119 #pragma GCC diagnostic warning "-Wctor-dtor-privacy"
120 #pragma GCC diagnostic warning "-Woverflow"
121 #pragma GCC diagnostic warning "-Wzero-as-null-pointer-constant"
122 #endif
123 
124 #if defined(__clang__)
125 #pragma clang diagnostic push
126 #pragma clang diagnostic ignored "-Wsign-conversion"
127 #pragma clang diagnostic ignored "-Wconversion"
128 #pragma clang diagnostic ignored "-Wdouble-promotion"
129 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
130 #pragma clang diagnostic ignored "-Wextra-semi"
131 #endif
132 
133 #include "absl/container/btree_map.h"
134 #include "absl/container/flat_hash_map.h"
135 #include "absl/container/node_hash_map.h"
136 #include "absl/hash/hash.h"
137 #include <map>
138 
139 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
140 #pragma GCC diagnostic pop
141 #endif
142 #if defined(__clang__)
143 #pragma clang diagnostic pop
144 #endif
145 
146 template <class T, class U, class Hash = typename absl::flat_hash_map<T, U>::hasher,
147  class Eq = typename absl::flat_hash_map<T, U>::key_equal, class Alloc = std::allocator<std::pair<const T, U>>>
148 using CustomUnorderedMap = absl::flat_hash_map<T, U, Hash, Eq, Alloc>;
149 
150 template <class T, class U, class Hash = typename absl::flat_hash_map<T, U>::hasher,
151  class Eq = typename absl::flat_hash_map<T, U>::key_equal, class Alloc = std::allocator<std::pair<const T, U>>>
152 using CustomUnorderedMapStable = absl::node_hash_map<T, U, Hash, Eq, Alloc>;
153 
154 template <class T, class U, class Hash = typename absl::flat_hash_map<T, U>::hasher,
155  class Eq = typename absl::flat_hash_map<T, U>::key_equal, class Alloc = std::allocator<std::pair<const T, U>>>
156 using CustomUnorderedMapUnstable = absl::flat_hash_map<T, U, Hash, Eq, Alloc>;
157 
158 template <typename T, typename U, typename Compare = std::less<T>,
159  typename Alloc = std::allocator<std::pair<const T, U>>>
160 using CustomOrderedMap = absl::btree_map<T, U, Compare, Alloc>;
161 
162 #if HAVE_UNORDERED
163 template <typename T, typename U>
165 #else
166 template <typename T, typename U>
168 #endif
169 
170 #endif
171 #endif
absl::btree_map< T, U, Compare, Alloc > CustomOrderedMap
Definition: custom_map.hpp:160
CustomOrderedMap< T, U > CustomMap
Definition: custom_map.hpp:167
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapUnstable
Definition: custom_map.hpp:156
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
Definition: custom_map.hpp:148
std::map< _Key, _Tp, _Compare, _Alloc > OrderedMapStd
Definition: custom_map.hpp:60
std::unordered_map< T, U, Hash, Eq, Alloc > UnorderedMapStd
Autoheader include.
Definition: custom_map.hpp:56
absl::node_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapStable
Definition: custom_map.hpp:152

Generated on Mon Feb 12 2024 13:02:56 for PandA-2024.02 by doxygen 1.8.13