3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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
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.
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/>.
20 #ifndef _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
21 #define _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
23 #include <bits/stdc++.h>
24 #include <ext/vstring.h>
29 // Base class with default false values for all traits.
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
;
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_push_pop
;
47 typedef std::false_type has_size_type_constructor
;
50 // Primary template does nothing. Specialize on each type under
51 // test, derive off of traits_base and just add the true traits.
52 template<typename _Tp
>
55 // Specialize for each container.
56 template<typename _Tp
, size_t _Np
>
57 struct traits
<std::array
<_Tp
, _Np
>> : public traits_base
59 typedef std::true_type is_container
;
60 typedef std::true_type is_reversible
;
63 template<typename _Tp1
, typename _Tp2
>
64 struct traits
<std::deque
<_Tp1
, _Tp2
>> : public traits_base
66 typedef std::true_type is_container
;
67 typedef std::true_type is_reversible
;
68 typedef std::true_type is_allocator_aware
;
70 typedef std::true_type has_erase
;
71 typedef std::true_type has_throwing_erase
;
72 typedef std::true_type has_insert
;
73 typedef std::true_type has_push_pop
;
74 typedef std::true_type has_size_type_constructor
;
77 template<typename _Tp1
, typename _Tp2
>
78 struct traits
<std::forward_list
<_Tp1
, _Tp2
>> : public traits_base
80 typedef std::true_type is_container
;
81 typedef std::true_type is_allocator_aware
;
83 typedef std::true_type has_erase_after
;
84 typedef std::true_type has_insert_after
;
85 typedef std::true_type has_push_pop
;
86 typedef std::true_type has_size_type_constructor
;
89 template<typename _Tp1
, typename _Tp2
>
90 struct traits
<std::list
<_Tp1
, _Tp2
>> : public traits_base
92 typedef std::true_type is_container
;
93 typedef std::true_type is_reversible
;
94 typedef std::true_type is_allocator_aware
;
96 typedef std::true_type has_erase
;
97 typedef std::true_type has_insert
;
98 typedef std::true_type has_push_pop
;
99 typedef std::true_type has_size_type_constructor
;
102 template<typename _Tp1
, typename _Tp2
>
103 struct traits
<std::vector
<_Tp1
, _Tp2
>> : public traits_base
105 typedef std::true_type is_container
;
106 typedef std::true_type is_reversible
;
107 typedef std::true_type is_allocator_aware
;
109 typedef std::true_type has_erase
;
110 typedef std::true_type has_throwing_erase
;
111 typedef std::true_type has_insert
;
112 typedef std::true_type has_size_type_constructor
;
115 template<typename _Tp1
, typename _Tp2
, typename _Tp3
>
116 struct traits
<std::basic_string
<_Tp1
, _Tp2
, _Tp3
>> : public traits_base
118 typedef std::true_type is_container
;
119 typedef std::true_type is_reversible
;
120 typedef std::true_type is_allocator_aware
;
122 typedef std::true_type has_erase
;
123 typedef std::true_type has_insert
;
126 template<typename _Tp1
, typename _Tp2
, typename _Tp3
,
127 template <typename
, typename
, typename
> class _Tp4
>
128 struct traits
<__gnu_cxx::__versa_string
<_Tp1
, _Tp2
, _Tp3
, _Tp4
>>
131 typedef std::true_type is_container
;
132 typedef std::true_type is_reversible
;
133 typedef std::true_type is_allocator_aware
;
135 typedef std::true_type has_erase
;
136 typedef std::true_type has_insert
;
139 template<typename _Tp1
, typename _Tp2
, typename _Tp3
, typename _Tp4
>
140 struct traits
<std::map
<_Tp1
, _Tp2
, _Tp3
, _Tp4
>> : public traits_base
142 typedef std::true_type is_container
;
143 typedef std::true_type is_reversible
;
144 typedef std::true_type is_allocator_aware
;
145 typedef std::true_type is_associative
;
146 typedef std::true_type is_mapped
;
148 typedef std::true_type has_erase
;
149 typedef std::true_type has_insert
;
152 template<typename _Tp1
, typename _Tp2
, typename _Tp3
, typename _Tp4
>
153 struct traits
<std::multimap
<_Tp1
, _Tp2
, _Tp3
, _Tp4
>> : public traits_base
155 typedef std::true_type is_container
;
156 typedef std::true_type is_reversible
;
157 typedef std::true_type is_allocator_aware
;
158 typedef std::true_type is_associative
;
159 typedef std::true_type is_mapped
;
161 typedef std::true_type has_erase
;
162 typedef std::true_type has_insert
;
165 template<typename _Tp1
, typename _Tp2
, typename _Tp3
>
166 struct traits
<std::set
<_Tp1
, _Tp2
, _Tp3
>> : public traits_base
168 typedef std::true_type is_container
;
169 typedef std::true_type is_reversible
;
170 typedef std::true_type is_allocator_aware
;
171 typedef std::true_type is_associative
;
173 typedef std::true_type has_erase
;
174 typedef std::true_type has_insert
;
177 template<typename _Tp1
, typename _Tp2
, typename _Tp3
>
178 struct traits
<std::multiset
<_Tp1
, _Tp2
, _Tp3
>> : public traits_base
180 typedef std::true_type is_container
;
181 typedef std::true_type is_reversible
;
182 typedef std::true_type is_allocator_aware
;
183 typedef std::true_type is_associative
;
185 typedef std::true_type has_erase
;
186 typedef std::true_type has_insert
;
189 template<typename _Tp1
, typename _Tp2
>
190 struct traits
<std::priority_queue
<_Tp1
, _Tp2
>> : public traits_base
192 typedef std::true_type is_adaptor
;
195 template<typename _Tp1
, typename _Tp2
>
196 struct traits
<std::queue
<_Tp1
, _Tp2
>> : public traits_base
198 typedef std::true_type is_adaptor
;
201 template<typename _Tp1
, typename _Tp2
>
202 struct traits
<std::stack
<_Tp1
, _Tp2
> > : public traits_base
204 typedef std::true_type is_adaptor
;
207 template<typename _Tp1
, typename _Tp2
, typename _Tp3
,
208 typename _Tp4
, typename _Tp5
>
209 struct traits
<std::unordered_map
<_Tp1
, _Tp2
, _Tp3
, _Tp4
, _Tp5
>>
212 typedef std::true_type is_container
;
213 typedef std::true_type is_allocator_aware
;
214 typedef std::true_type is_unordered
;
215 typedef std::true_type is_mapped
;
217 typedef std::true_type has_erase
;
218 typedef std::true_type has_insert
;
221 template<typename _Tp1
, typename _Tp2
, typename _Tp3
,
222 typename _Tp4
, typename _Tp5
>
223 struct traits
<std::unordered_multimap
<_Tp1
, _Tp2
, _Tp3
, _Tp4
, _Tp5
>>
226 typedef std::true_type is_container
;
227 typedef std::true_type is_allocator_aware
;
228 typedef std::true_type is_unordered
;
229 typedef std::true_type is_mapped
;
231 typedef std::true_type has_erase
;
232 typedef std::true_type has_insert
;
235 template<typename _Tp1
, typename _Tp2
, typename _Tp3
, typename _Tp4
>
236 struct traits
<std::unordered_multiset
<_Tp1
, _Tp2
, _Tp3
, _Tp4
>>
239 typedef std::true_type is_container
;
240 typedef std::true_type is_allocator_aware
;
241 typedef std::true_type is_unordered
;
243 typedef std::true_type has_erase
;
244 typedef std::true_type has_insert
;
247 template<typename _Tp1
, typename _Tp2
, typename _Tp3
, typename _Tp4
>
248 struct traits
<std::unordered_set
<_Tp1
, _Tp2
, _Tp3
, _Tp4
>>
251 typedef std::true_type is_container
;
252 typedef std::true_type is_allocator_aware
;
253 typedef std::true_type is_unordered
;
255 typedef std::true_type has_erase
;
256 typedef std::true_type has_insert
;
258 } // namespace __gnu_test