111
|
1 // -*- C++ -*-
|
|
2
|
145
|
3 // Copyright (C) 2009-2020 Free Software Foundation, Inc.
|
111
|
4 //
|
|
5 // This file is part of the GNU ISO C++ Library. This library is free
|
|
6 // software; you can redistribute it and/or modify it under the terms
|
|
7 // of the GNU General Public License as published by the Free Software
|
|
8 // Foundation; either version 3, or (at your option) any later
|
|
9 // version.
|
|
10
|
|
11 // This library is distributed in the hope that it will be useful, but
|
|
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 // General Public License for more details.
|
|
15
|
|
16 // You should have received a copy of the GNU General Public License along
|
|
17 // with this library; see the file COPYING3. If not see
|
|
18 // <http://www.gnu.org/licenses/>.
|
|
19
|
|
20 #ifndef _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
|
|
21 #define _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
|
|
22
|
|
23 #include <bits/stdc++.h>
|
|
24 #include <ext/vstring.h>
|
|
25
|
|
26 namespace __gnu_test
|
|
27 {
|
|
28 // Container traits.
|
|
29 // Base class with default false values for all traits.
|
|
30 struct traits_base
|
|
31 {
|
|
32 // Type, nested type, and typedef related traits.
|
|
33 typedef std::false_type is_container;
|
|
34 typedef std::false_type is_adaptor;
|
|
35 typedef std::false_type is_reversible;
|
|
36 typedef std::false_type is_allocator_aware;
|
|
37 typedef std::false_type is_associative;
|
|
38 typedef std::false_type is_unordered;
|
|
39 typedef std::false_type is_mapped;
|
|
40
|
|
41 typedef std::false_type has_erase;
|
|
42 typedef std::false_type has_erase_after;
|
|
43 typedef std::false_type has_throwing_erase;
|
|
44 typedef std::false_type has_insert;
|
|
45 typedef std::false_type has_insert_after;
|
|
46 typedef std::false_type has_emplace;
|
|
47 typedef std::false_type has_push_pop;
|
|
48 typedef std::false_type has_size_type_constructor;
|
|
49 };
|
|
50
|
|
51 // Primary template does nothing. Specialize on each type under
|
|
52 // test, derive off of traits_base and just add the true traits.
|
|
53 template<typename _Tp>
|
|
54 struct traits;
|
|
55
|
|
56 // Specialize for each container.
|
|
57 template<typename _Tp, size_t _Np>
|
|
58 struct traits<std::array<_Tp, _Np>> : public traits_base
|
|
59 {
|
|
60 typedef std::true_type is_container;
|
|
61 typedef std::true_type is_reversible;
|
|
62 };
|
|
63
|
|
64 template<typename _Tp1, typename _Tp2>
|
|
65 struct traits<std::deque<_Tp1, _Tp2>> : public traits_base
|
|
66 {
|
|
67 typedef std::true_type is_container;
|
|
68 typedef std::true_type is_reversible;
|
|
69 typedef std::true_type is_allocator_aware;
|
|
70
|
|
71 typedef std::true_type has_erase;
|
|
72 typedef std::true_type has_throwing_erase;
|
|
73 typedef std::true_type has_insert;
|
|
74 typedef std::true_type has_push_pop;
|
|
75 typedef std::true_type has_size_type_constructor;
|
|
76 typedef std::true_type has_emplace;
|
|
77 };
|
|
78
|
|
79 template<typename _Tp1, typename _Tp2>
|
|
80 struct traits<std::forward_list<_Tp1, _Tp2>> : public traits_base
|
|
81 {
|
|
82 typedef std::true_type is_container;
|
|
83 typedef std::true_type is_allocator_aware;
|
|
84
|
|
85 typedef std::true_type has_erase_after;
|
|
86 typedef std::true_type has_insert_after;
|
|
87 typedef std::true_type has_push_pop;
|
|
88 typedef std::true_type has_size_type_constructor;
|
|
89 typedef std::true_type has_emplace;
|
|
90 };
|
|
91
|
|
92 template<typename _Tp1, typename _Tp2>
|
|
93 struct traits<std::list<_Tp1, _Tp2>> : public traits_base
|
|
94 {
|
|
95 typedef std::true_type is_container;
|
|
96 typedef std::true_type is_reversible;
|
|
97 typedef std::true_type is_allocator_aware;
|
|
98
|
|
99 typedef std::true_type has_erase;
|
|
100 typedef std::true_type has_insert;
|
|
101 typedef std::true_type has_push_pop;
|
|
102 typedef std::true_type has_size_type_constructor;
|
|
103 typedef std::true_type has_emplace;
|
|
104 };
|
|
105
|
|
106 template<typename _Tp1, typename _Tp2>
|
|
107 struct traits<std::vector<_Tp1, _Tp2>> : public traits_base
|
|
108 {
|
|
109 typedef std::true_type is_container;
|
|
110 typedef std::true_type is_reversible;
|
|
111 typedef std::true_type is_allocator_aware;
|
|
112
|
|
113 typedef std::true_type has_erase;
|
|
114 typedef std::true_type has_throwing_erase;
|
|
115 typedef std::true_type has_insert;
|
|
116 typedef std::true_type has_size_type_constructor;
|
|
117 typedef std::true_type has_emplace;
|
|
118 };
|
|
119
|
|
120 template<typename _Tp1, typename _Tp2, typename _Tp3>
|
|
121 struct traits<std::basic_string<_Tp1, _Tp2, _Tp3>> : public traits_base
|
|
122 {
|
|
123 typedef std::true_type is_container;
|
|
124 typedef std::true_type is_reversible;
|
|
125 typedef std::true_type is_allocator_aware;
|
|
126
|
|
127 typedef std::true_type has_erase;
|
|
128 typedef std::true_type has_insert;
|
|
129 };
|
|
130
|
|
131 template<typename _Tp1, typename _Tp2, typename _Tp3,
|
|
132 template <typename, typename, typename> class _Tp4>
|
|
133 struct traits<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
|
|
134 : public traits_base
|
|
135 {
|
|
136 typedef std::true_type is_container;
|
|
137 typedef std::true_type is_reversible;
|
|
138 typedef std::true_type is_allocator_aware;
|
|
139
|
|
140 typedef std::true_type has_erase;
|
|
141 typedef std::true_type has_insert;
|
|
142 };
|
|
143
|
|
144 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
|
|
145 struct traits<std::map<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
|
|
146 {
|
|
147 typedef std::true_type is_container;
|
|
148 typedef std::true_type is_reversible;
|
|
149 typedef std::true_type is_allocator_aware;
|
|
150 typedef std::true_type is_associative;
|
|
151 typedef std::true_type is_mapped;
|
|
152
|
|
153 typedef std::true_type has_erase;
|
|
154 typedef std::true_type has_insert;
|
|
155 typedef std::true_type has_emplace;
|
|
156 };
|
|
157
|
|
158 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
|
|
159 struct traits<std::multimap<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
|
|
160 {
|
|
161 typedef std::true_type is_container;
|
|
162 typedef std::true_type is_reversible;
|
|
163 typedef std::true_type is_allocator_aware;
|
|
164 typedef std::true_type is_associative;
|
|
165 typedef std::true_type is_mapped;
|
|
166
|
|
167 typedef std::true_type has_erase;
|
|
168 typedef std::true_type has_insert;
|
|
169 typedef std::true_type has_emplace;
|
|
170 };
|
|
171
|
|
172 template<typename _Tp1, typename _Tp2, typename _Tp3>
|
|
173 struct traits<std::set<_Tp1, _Tp2, _Tp3>> : public traits_base
|
|
174 {
|
|
175 typedef std::true_type is_container;
|
|
176 typedef std::true_type is_reversible;
|
|
177 typedef std::true_type is_allocator_aware;
|
|
178 typedef std::true_type is_associative;
|
|
179
|
|
180 typedef std::true_type has_erase;
|
|
181 typedef std::true_type has_insert;
|
|
182 typedef std::true_type has_emplace;
|
|
183 };
|
|
184
|
|
185 template<typename _Tp1, typename _Tp2, typename _Tp3>
|
|
186 struct traits<std::multiset<_Tp1, _Tp2, _Tp3>> : public traits_base
|
|
187 {
|
|
188 typedef std::true_type is_container;
|
|
189 typedef std::true_type is_reversible;
|
|
190 typedef std::true_type is_allocator_aware;
|
|
191 typedef std::true_type is_associative;
|
|
192
|
|
193 typedef std::true_type has_erase;
|
|
194 typedef std::true_type has_insert;
|
|
195 typedef std::true_type has_emplace;
|
|
196 };
|
|
197
|
|
198 template<typename _Tp1, typename _Tp2>
|
|
199 struct traits<std::priority_queue<_Tp1, _Tp2>> : public traits_base
|
|
200 {
|
|
201 typedef std::true_type is_adaptor;
|
|
202 };
|
|
203
|
|
204 template<typename _Tp1, typename _Tp2>
|
|
205 struct traits<std::queue<_Tp1, _Tp2>> : public traits_base
|
|
206 {
|
|
207 typedef std::true_type is_adaptor;
|
|
208 };
|
|
209
|
|
210 template<typename _Tp1, typename _Tp2>
|
|
211 struct traits<std::stack<_Tp1, _Tp2> > : public traits_base
|
|
212 {
|
|
213 typedef std::true_type is_adaptor;
|
|
214 };
|
|
215
|
|
216 template<typename _Tp1, typename _Tp2, typename _Tp3,
|
|
217 typename _Tp4, typename _Tp5>
|
|
218 struct traits<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
|
|
219 : public traits_base
|
|
220 {
|
|
221 typedef std::true_type is_container;
|
|
222 typedef std::true_type is_allocator_aware;
|
|
223 typedef std::true_type is_unordered;
|
|
224 typedef std::true_type is_mapped;
|
|
225
|
|
226 typedef std::true_type has_erase;
|
|
227 typedef std::true_type has_insert;
|
|
228 typedef std::true_type has_emplace;
|
|
229 };
|
|
230
|
|
231 template<typename _Tp1, typename _Tp2, typename _Tp3,
|
|
232 typename _Tp4, typename _Tp5>
|
|
233 struct traits<std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
|
|
234 : public traits_base
|
|
235 {
|
|
236 typedef std::true_type is_container;
|
|
237 typedef std::true_type is_allocator_aware;
|
|
238 typedef std::true_type is_unordered;
|
|
239 typedef std::true_type is_mapped;
|
|
240
|
|
241 typedef std::true_type has_erase;
|
|
242 typedef std::true_type has_insert;
|
|
243 typedef std::true_type has_emplace;
|
|
244 };
|
|
245
|
|
246 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
|
|
247 struct traits<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>>
|
|
248 : public traits_base
|
|
249 {
|
|
250 typedef std::true_type is_container;
|
|
251 typedef std::true_type is_allocator_aware;
|
|
252 typedef std::true_type is_unordered;
|
|
253
|
|
254 typedef std::true_type has_erase;
|
|
255 typedef std::true_type has_insert;
|
|
256 typedef std::true_type has_emplace;
|
|
257 };
|
|
258
|
|
259 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
|
|
260 struct traits<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>>
|
|
261 : public traits_base
|
|
262 {
|
|
263 typedef std::true_type is_container;
|
|
264 typedef std::true_type is_allocator_aware;
|
|
265 typedef std::true_type is_unordered;
|
|
266
|
|
267 typedef std::true_type has_erase;
|
|
268 typedef std::true_type has_insert;
|
|
269 typedef std::true_type has_emplace;
|
|
270 };
|
|
271 } // namespace __gnu_test
|
|
272
|
|
273 #endif
|