OSDN Git Service

2010-02-19 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_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_insert;
43     typedef std::false_type     has_push_pop;
44     typedef std::false_type     has_size_type_constructor;
45   };
46
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>
50     struct traits;
51
52   // Specialize for each container.
53   template<typename _Tp, size_t _Np>
54     struct traits<std::array<_Tp, _Np>> : public traits_base
55     {
56       typedef std::true_type    is_container;
57       typedef std::true_type    is_reversible;
58     };
59
60   template<typename _Tp1, typename _Tp2>
61     struct traits<std::deque<_Tp1, _Tp2>> : public traits_base
62     {
63       typedef std::true_type    is_container;
64       typedef std::true_type    is_reversible;
65       typedef std::true_type    is_allocator_aware;
66
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;
71     };
72
73   template<typename _Tp1, typename _Tp2>
74     struct traits<std::forward_list<_Tp1, _Tp2>> : public traits_base
75     {
76       typedef std::true_type    is_container;
77       typedef std::true_type    is_allocator_aware;
78
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;
83     };
84
85   template<typename _Tp1, typename _Tp2>
86     struct traits<std::list<_Tp1, _Tp2>> : public traits_base
87     {
88       typedef std::true_type    is_container;
89       typedef std::true_type    is_reversible;
90       typedef std::true_type    is_allocator_aware;
91
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;
96     };
97
98   template<typename _Tp1, typename _Tp2>
99     struct traits<std::vector<_Tp1, _Tp2>> : public traits_base
100     {
101       typedef std::true_type    is_container;
102       typedef std::true_type    is_reversible;
103       typedef std::true_type    is_allocator_aware;
104
105       typedef std::true_type    has_erase;
106       typedef std::true_type    has_insert;
107       typedef std::true_type    has_size_type_constructor;
108     };
109
110   template<typename _Tp1, typename _Tp2, typename _Tp3>
111     struct traits<std::basic_string<_Tp1, _Tp2, _Tp3>> : public traits_base
112     {
113       typedef std::true_type    is_container;
114       typedef std::true_type    is_reversible;
115       typedef std::true_type    is_allocator_aware;
116
117       typedef std::true_type    has_erase;
118       typedef std::true_type    has_insert;
119     };
120
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>>
124     : public traits_base
125     {
126       typedef std::true_type    is_container;
127       typedef std::true_type    is_reversible;
128       typedef std::true_type    is_allocator_aware;
129
130       typedef std::true_type    has_erase;
131       typedef std::true_type    has_insert;
132     };
133
134   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
135     struct traits<std::map<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
136     {
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;
142
143       typedef std::true_type    has_insert;
144     };
145
146   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
147     struct traits<std::multimap<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
148     {
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;
154
155       typedef std::true_type    has_insert;
156     };
157
158   template<typename _Tp1, typename _Tp2, typename _Tp3>
159     struct traits<std::set<_Tp1, _Tp2, _Tp3>> : 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
166       typedef std::true_type    has_insert;
167     };
168
169   template<typename _Tp1, typename _Tp2, typename _Tp3>
170     struct traits<std::multiset<_Tp1, _Tp2, _Tp3>> : public traits_base
171     {
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;
176
177       typedef std::true_type    has_insert;
178     };
179
180   template<typename _Tp1, typename _Tp2>
181     struct traits<std::priority_queue<_Tp1, _Tp2>> : public traits_base
182     {
183       typedef std::true_type    is_adaptor;
184     };
185
186   template<typename _Tp1, typename _Tp2>
187     struct traits<std::queue<_Tp1, _Tp2>> : public traits_base
188     {
189       typedef std::true_type    is_adaptor;
190     };
191
192   template<typename _Tp1, typename _Tp2>
193     struct traits<std::stack<_Tp1, _Tp2> > : public traits_base
194     {
195       typedef std::true_type    is_adaptor;
196     };
197
198   template<typename _Tp1, typename _Tp2, typename _Tp3,
199            typename _Tp4, typename _Tp5>
200     struct traits<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
201     : public traits_base
202     {
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;
207
208       typedef std::true_type    has_size_type_constructor;
209       typedef std::true_type    has_insert;
210     };
211
212   template<typename _Tp1, typename _Tp2, typename _Tp3,
213            typename _Tp4, typename _Tp5>
214     struct traits<std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
215     : public traits_base
216     {
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;
221
222       typedef std::true_type    has_size_type_constructor;
223     };
224
225   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
226     struct traits<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>>
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_unordered;
232
233       typedef std::true_type    has_size_type_constructor;
234       typedef std::true_type    has_insert;
235     };
236
237   template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
238     struct traits<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>>
239     : public traits_base
240     {
241       typedef std::true_type    is_container;
242       typedef std::true_type    is_allocator_aware;
243       typedef std::true_type    is_unordered;
244
245       typedef std::true_type    has_size_type_constructor;
246       typedef std::true_type    has_insert;
247     };
248 } // namespace __gnu_test
249
250 #endif