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_insert;
43 typedef std::false_type has_push_pop;
44 typedef std::false_type has_size_type_constructor;
47 // Primary template does nothing. Specialize on each type under
48 // test, derive off of traits_base and just add the true traits.
49 template<typename _Tp>
52 // Specialize for each container.
53 template<typename _Tp, size_t _Np>
54 struct traits<std::array<_Tp, _Np>> : public traits_base
56 typedef std::true_type is_container;
57 typedef std::true_type is_reversible;
60 template<typename _Tp1, typename _Tp2>
61 struct traits<std::deque<_Tp1, _Tp2>> : public traits_base
63 typedef std::true_type is_container;
64 typedef std::true_type is_reversible;
65 typedef std::true_type is_allocator_aware;
67 typedef std::true_type has_erase;
68 typedef std::true_type has_insert;
69 typedef std::true_type has_push_pop;
70 typedef std::true_type has_size_type_constructor;
73 template<typename _Tp1, typename _Tp2>
74 struct traits<std::forward_list<_Tp1, _Tp2>> : public traits_base
76 typedef std::true_type is_container;
77 typedef std::true_type is_allocator_aware;
79 typedef std::true_type has_erase;
80 typedef std::true_type has_insert;
81 typedef std::true_type has_push_pop;
82 typedef std::true_type has_size_type_constructor;
85 template<typename _Tp1, typename _Tp2>
86 struct traits<std::list<_Tp1, _Tp2>> : public traits_base
88 typedef std::true_type is_container;
89 typedef std::true_type is_reversible;
90 typedef std::true_type is_allocator_aware;
92 typedef std::true_type has_erase;
93 typedef std::true_type has_insert;
94 typedef std::true_type has_push_pop;
95 typedef std::true_type has_size_type_constructor;
98 template<typename _Tp1, typename _Tp2>
99 struct traits<std::vector<_Tp1, _Tp2>> : public traits_base
101 typedef std::true_type is_container;
102 typedef std::true_type is_reversible;
103 typedef std::true_type is_allocator_aware;
105 typedef std::true_type has_erase;
106 typedef std::true_type has_insert;
107 typedef std::true_type has_size_type_constructor;
110 template<typename _Tp1, typename _Tp2, typename _Tp3>
111 struct traits<std::basic_string<_Tp1, _Tp2, _Tp3>> : public traits_base
113 typedef std::true_type is_container;
114 typedef std::true_type is_reversible;
115 typedef std::true_type is_allocator_aware;
117 typedef std::true_type has_erase;
118 typedef std::true_type has_insert;
121 template<typename _Tp1, typename _Tp2, typename _Tp3,
122 template <typename, typename, typename> class _Tp4>
123 struct traits<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
126 typedef std::true_type is_container;
127 typedef std::true_type is_reversible;
128 typedef std::true_type is_allocator_aware;
130 typedef std::true_type has_erase;
131 typedef std::true_type has_insert;
134 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
135 struct traits<std::map<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
137 typedef std::true_type is_container;
138 typedef std::true_type is_reversible;
139 typedef std::true_type is_allocator_aware;
140 typedef std::true_type is_associative;
141 typedef std::true_type is_mapped;
143 typedef std::true_type has_insert;
146 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
147 struct traits<std::multimap<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
149 typedef std::true_type is_container;
150 typedef std::true_type is_reversible;
151 typedef std::true_type is_allocator_aware;
152 typedef std::true_type is_associative;
153 typedef std::true_type is_mapped;
155 typedef std::true_type has_insert;
158 template<typename _Tp1, typename _Tp2, typename _Tp3>
159 struct traits<std::set<_Tp1, _Tp2, _Tp3>> : public traits_base
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;
166 typedef std::true_type has_insert;
169 template<typename _Tp1, typename _Tp2, typename _Tp3>
170 struct traits<std::multiset<_Tp1, _Tp2, _Tp3>> : public traits_base
172 typedef std::true_type is_container;
173 typedef std::true_type is_reversible;
174 typedef std::true_type is_allocator_aware;
175 typedef std::true_type is_associative;
177 typedef std::true_type has_insert;
180 template<typename _Tp1, typename _Tp2>
181 struct traits<std::priority_queue<_Tp1, _Tp2>> : public traits_base
183 typedef std::true_type is_adaptor;
186 template<typename _Tp1, typename _Tp2>
187 struct traits<std::queue<_Tp1, _Tp2>> : public traits_base
189 typedef std::true_type is_adaptor;
192 template<typename _Tp1, typename _Tp2>
193 struct traits<std::stack<_Tp1, _Tp2> > : public traits_base
195 typedef std::true_type is_adaptor;
198 template<typename _Tp1, typename _Tp2, typename _Tp3,
199 typename _Tp4, typename _Tp5>
200 struct traits<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
203 typedef std::true_type is_container;
204 typedef std::true_type is_allocator_aware;
205 typedef std::true_type is_unordered;
206 typedef std::true_type is_mapped;
208 typedef std::true_type has_size_type_constructor;
209 typedef std::true_type has_insert;
212 template<typename _Tp1, typename _Tp2, typename _Tp3,
213 typename _Tp4, typename _Tp5>
214 struct traits<std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
217 typedef std::true_type is_container;
218 typedef std::true_type is_allocator_aware;
219 typedef std::true_type is_unordered;
220 typedef std::true_type is_mapped;
222 typedef std::true_type has_size_type_constructor;
225 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
226 struct traits<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>>
229 typedef std::true_type is_container;
230 typedef std::true_type is_allocator_aware;
231 typedef std::true_type is_unordered;
233 typedef std::true_type has_size_type_constructor;
234 typedef std::true_type has_insert;
237 template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
238 struct traits<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>>
241 typedef std::true_type is_container;
242 typedef std::true_type is_allocator_aware;
243 typedef std::true_type is_unordered;
245 typedef std::true_type has_size_type_constructor;
246 typedef std::true_type has_insert;
248 } // namespace __gnu_test