OSDN Git Service

2010-01-31 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / util / testsuite_container_traits.h
1 // -*- C++ -*-
2
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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_pointer_aware;
38     typedef std::false_type     is_associative;
39     typedef std::false_type     is_unordered;
40     typedef std::false_type     is_mapped;
41
42     typedef std::false_type     has_erase;
43     typedef std::false_type     has_insert;
44     typedef std::false_type     has_push_pop;
45     typedef std::false_type     has_size_type_constructor;
46   };
47
48   // Primary template does nothing. Specialize on each type under
49   // test, derive off of traits_base and just add the true traits.
50   template<typename _Tp>
51     struct traits;
52
53   // Specialize for each container.
54   template<typename _Tp, size_t _Np>
55     struct traits<std::array<_Tp, _Np>> : public traits_base
56     {
57       typedef std::true_type    is_container;
58       typedef std::true_type    is_reversible;
59     };
60
61   template<typename _Tp1, typename _Tp2>
62     struct traits<std::deque<_Tp1, _Tp2>> : public traits_base
63     {
64       typedef std::true_type    is_container;
65       typedef std::true_type    is_reversible;
66       typedef std::true_type    is_allocator_aware;
67       typedef std::true_type    is_pointer_aware;
68
69       typedef std::true_type    has_erase;
70       typedef std::true_type    has_insert;
71       typedef std::true_type    has_push_pop;
72       typedef std::true_type    has_size_type_constructor;
73     };
74
75   template<typename _Tp1, typename _Tp2>
76     struct traits<std::forward_list<_Tp1, _Tp2>> : public traits_base
77     {
78       typedef std::true_type    is_container;
79       typedef std::true_type    is_allocator_aware;
80       typedef std::true_type    is_pointer_aware;
81
82       typedef std::true_type    has_erase;
83       typedef std::true_type    has_insert;
84       typedef std::true_type    has_push_pop;
85       typedef std::true_type    has_size_type_constructor;
86     };
87
88   template<typename _Tp1, typename _Tp2>
89     struct traits<std::list<_Tp1, _Tp2>> : public traits_base
90     {
91       typedef std::true_type    is_container;
92       typedef std::true_type    is_reversible;
93       typedef std::true_type    is_allocator_aware;
94       typedef std::true_type    is_pointer_aware;
95
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;
100     };
101
102   template<typename _Tp1, typename _Tp2>
103     struct traits<std::vector<_Tp1, _Tp2>> : public traits_base
104     {
105       typedef std::true_type    is_container;
106       typedef std::true_type    is_reversible;
107       typedef std::true_type    is_allocator_aware;
108       typedef std::true_type    is_pointer_aware;
109
110       typedef std::true_type    has_erase;
111       typedef std::true_type    has_insert;
112       typedef std::true_type    has_size_type_constructor;
113     };
114
115   template<typename _Tp1, typename _Tp2, typename _Tp3>
116     struct traits<std::basic_string<_Tp1, _Tp2, _Tp3>> : public traits_base
117     {
118       typedef std::true_type    is_container;
119       typedef std::true_type    is_reversible;
120       typedef std::true_type    is_allocator_aware;
121       typedef std::true_type    is_pointer_aware;
122
123       typedef std::true_type    has_erase;
124       typedef std::true_type    has_insert;
125     };
126
127   template<typename _Tp1, typename _Tp2, typename _Tp3,
128            template <typename, typename, typename> class _Tp4>
129     struct traits<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
130     : public traits_base
131     {
132       typedef std::true_type    is_container;
133       typedef std::true_type    is_reversible;
134       typedef std::true_type    is_allocator_aware;
135       typedef std::true_type    is_pointer_aware;
136
137       typedef std::true_type    has_erase;
138       typedef std::true_type    has_insert;
139     };
140
141   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
142     struct traits<std::map<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
143     {
144       typedef std::true_type    is_container;
145       typedef std::true_type    is_reversible;
146       typedef std::true_type    is_allocator_aware;
147       typedef std::true_type    is_pointer_aware;
148       typedef std::true_type    is_associative;
149       typedef std::true_type    is_mapped;
150
151       typedef std::true_type    has_insert;
152     };
153
154   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
155     struct traits<std::multimap<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
156     {
157       typedef std::true_type    is_container;
158       typedef std::true_type    is_reversible;
159       typedef std::true_type    is_allocator_aware;
160       typedef std::true_type    is_pointer_aware;
161       typedef std::true_type    is_associative;
162       typedef std::true_type    is_mapped;
163
164       typedef std::true_type    has_insert;
165     };
166
167   template<typename _Tp1, typename _Tp2, typename _Tp3>
168     struct traits<std::set<_Tp1, _Tp2, _Tp3>> : public traits_base
169     {
170       typedef std::true_type    is_container;
171       typedef std::true_type    is_reversible;
172       typedef std::true_type    is_allocator_aware;
173       typedef std::true_type    is_pointer_aware;
174       typedef std::true_type    is_associative;
175
176       typedef std::true_type    has_insert;
177     };
178
179   template<typename _Tp1, typename _Tp2, typename _Tp3>
180     struct traits<std::multiset<_Tp1, _Tp2, _Tp3>> : public traits_base
181     {
182       typedef std::true_type    is_container;
183       typedef std::true_type    is_reversible;
184       typedef std::true_type    is_allocator_aware;
185       typedef std::true_type    is_pointer_aware;
186       typedef std::true_type    is_associative;
187
188       typedef std::true_type    has_insert;
189     };
190
191   template<typename _Tp1, typename _Tp2>
192     struct traits<std::priority_queue<_Tp1, _Tp2>> : public traits_base
193     {
194       typedef std::true_type    is_adaptor;
195     };
196
197   template<typename _Tp1, typename _Tp2>
198     struct traits<std::queue<_Tp1, _Tp2>> : public traits_base
199     {
200       typedef std::true_type    is_adaptor;
201     };
202
203   template<typename _Tp1, typename _Tp2>
204     struct traits<std::stack<_Tp1, _Tp2> > : public traits_base
205     {
206       typedef std::true_type    is_adaptor;
207     };
208
209   template<typename _Tp1, typename _Tp2, typename _Tp3,
210            typename _Tp4, typename _Tp5>
211     struct traits<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
212     : public traits_base
213     {
214       typedef std::true_type    is_container;
215       typedef std::true_type    is_allocator_aware;
216       typedef std::true_type    is_pointer_aware;
217       typedef std::true_type    is_unordered;
218       typedef std::true_type    is_mapped;
219
220       typedef std::true_type    has_size_type_constructor;
221       typedef std::true_type    has_insert;
222     };
223
224   template<typename _Tp1, typename _Tp2, typename _Tp3,
225            typename _Tp4, typename _Tp5>
226     struct traits<std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
227     : public traits_base
228     {
229       typedef std::true_type    is_container;
230       typedef std::true_type    is_allocator_aware;
231       typedef std::true_type    is_pointer_aware;
232       typedef std::true_type    is_unordered;
233       typedef std::true_type    is_mapped;
234
235       typedef std::true_type    has_size_type_constructor;
236     };
237
238   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
239     struct traits<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>>
240     : public traits_base
241     {
242       typedef std::true_type    is_container;
243       typedef std::true_type    is_allocator_aware;
244       typedef std::true_type    is_pointer_aware;
245       typedef std::true_type    is_unordered;
246
247       typedef std::true_type    has_size_type_constructor;
248       typedef std::true_type    has_insert;
249     };
250
251   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
252     struct traits<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>>
253     : public traits_base
254     {
255       typedef std::true_type    is_container;
256       typedef std::true_type    is_allocator_aware;
257       typedef std::true_type    is_pointer_aware;
258       typedef std::true_type    is_unordered;
259
260       typedef std::true_type    has_size_type_constructor;
261       typedef std::true_type    has_insert;
262     };
263 } // namespace __gnu_test
264
265 #endif