2 // typelist for the C++ library testsuite.
4 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 #ifndef _TESTSUITE_COMMON_TYPES_H
23 #define _TESTSUITE_COMMON_TYPES_H 1
25 #include <ext/typelist.h>
27 #include <ext/new_allocator.h>
28 #include <ext/malloc_allocator.h>
29 #include <ext/mt_allocator.h>
30 #include <ext/bitmap_allocator.h>
31 #include <ext/pool_allocator.h>
42 #include <tr1/functional>
43 #include <tr1/unordered_map>
44 #include <tr1/unordered_set>
46 #ifdef __GXX_EXPERIMENTAL_CXX0X__
48 #include <type_traits>
53 using __gnu_cxx::typelist::node
;
54 using __gnu_cxx::typelist::transform
;
55 using __gnu_cxx::typelist::append
;
57 // All the allocators to test.
58 template<typename Tp
, bool Thread
>
59 struct allocator_policies
61 typedef Tp value_type
;
62 typedef __gnu_cxx::new_allocator
<Tp
> a1
;
63 typedef __gnu_cxx::malloc_allocator
<Tp
> a2
;
64 typedef __gnu_cxx::__common_pool_policy
<__gnu_cxx::__pool
, Thread
> pool_policy
;
65 typedef __gnu_cxx::__mt_alloc
<Tp
, pool_policy
> a3
;
66 typedef __gnu_cxx::bitmap_allocator
<Tp
> a4
;
67 typedef __gnu_cxx::__pool_alloc
<Tp
> a5
;
68 typedef node
<_GLIBCXX_TYPELIST_CHAIN5(a1
, a2
, a3
, a4
, a5
)> type
;
71 // Typelists for vector, string, list, deque.
72 // XXX should just use template templates
73 template<typename Tp
, bool Thread
>
76 typedef Tp value_type
;
81 typedef Tl allocator_type
;
82 typedef std::vector
<value_type
, allocator_type
> type
;
85 typedef allocator_policies
<value_type
, Thread
> allocator_types
;
86 typedef typename
allocator_types::type allocator_typelist
;
87 typedef typename transform
<allocator_typelist
, vector_shell
>::type type
;
90 template<typename Tp
, bool Thread
>
93 typedef Tp value_type
;
98 typedef Tl allocator_type
;
99 typedef std::list
<value_type
, allocator_type
> type
;
102 typedef allocator_policies
<value_type
, Thread
> allocator_types
;
103 typedef typename
allocator_types::type allocator_typelist
;
104 typedef typename transform
<allocator_typelist
, list_shell
>::type type
;
107 template<typename Tp
, bool Thread
>
110 typedef Tp value_type
;
112 template<typename Tl
>
115 typedef Tl allocator_type
;
116 typedef std::deque
<value_type
, allocator_type
> type
;
119 typedef allocator_policies
<value_type
, Thread
> allocator_types
;
120 typedef typename
allocator_types::type allocator_typelist
;
121 typedef typename transform
<allocator_typelist
, deque_shell
>::type type
;
124 template<typename Tp
, bool Thread
>
127 typedef Tp value_type
;
129 template<typename Tl
>
132 typedef Tl allocator_type
;
133 typedef std::char_traits
<value_type
> traits_type
;
134 typedef std::basic_string
<value_type
, traits_type
, allocator_type
> type
;
137 typedef allocator_policies
<value_type
, Thread
> allocator_types
;
138 typedef typename
allocator_types::type allocator_typelist
;
139 typedef typename transform
<allocator_typelist
, string_shell
>::type type
;
142 // A typelist of vector, list, deque, and string all instantiated
143 // with each of the allocator policies.
144 template<typename Tp
, bool Thread
>
145 struct sequence_containers
147 typedef Tp value_type
;
149 typedef typename vectors
<value_type
, Thread
>::type vector_typelist
;
150 typedef typename lists
<value_type
, Thread
>::type list_typelist
;
151 typedef typename deques
<value_type
, Thread
>::type deque_typelist
;
152 typedef typename strings
<value_type
, Thread
>::type string_typelist
;
154 typedef typename append
<vector_typelist
, list_typelist
>::type a1
;
155 typedef typename append
<deque_typelist
, string_typelist
>::type a2
;
156 typedef typename append
<a1
, a2
>::type type
;
159 // Typelists for map, set, unordered_set, unordered_map.
160 template<typename Tp
, bool Thread
>
163 typedef Tp value_type
;
165 typedef std::pair
<const key_type
, value_type
> pair_type
;
166 typedef std::less
<key_type
> compare_function
;
168 template<typename Tl
>
171 typedef Tl allocator_type
;
172 typedef std::map
<key_type
, value_type
, compare_function
, allocator_type
> type
;
175 typedef allocator_policies
<pair_type
, Thread
> allocator_types
;
176 typedef typename
allocator_types::type allocator_typelist
;
177 typedef typename transform
<allocator_typelist
, container
>::type type
;
180 template<typename Tp
, bool Thread
>
181 struct unordered_maps
183 typedef Tp value_type
;
185 typedef std::pair
<const key_type
, value_type
> pair_type
;
186 typedef std::tr1::hash
<key_type
> hash_function
;
187 typedef std::equal_to
<key_type
> equality_function
;
189 template<typename Tl
>
192 typedef Tl allocator_type
;
193 typedef std::tr1::unordered_map
<key_type
, value_type
, hash_function
, equality_function
, allocator_type
> type
;
196 typedef allocator_policies
<pair_type
, Thread
> allocator_types
;
197 typedef typename
allocator_types::type allocator_typelist
;
198 typedef typename transform
<allocator_typelist
, container
>::type type
;
201 template<typename Tp
, bool Thread
>
204 typedef Tp value_type
;
206 typedef std::less
<key_type
> compare_function
;
208 template<typename Tl
>
211 typedef Tl allocator_type
;
212 typedef std::set
<key_type
, compare_function
, allocator_type
> type
;
215 typedef allocator_policies
<key_type
, Thread
> allocator_types
;
216 typedef typename
allocator_types::type allocator_typelist
;
217 typedef typename transform
<allocator_typelist
, container
>::type type
;
220 template<typename Tp
, bool Thread
>
221 struct unordered_sets
223 typedef Tp value_type
;
225 typedef std::tr1::hash
<key_type
> hash_function
;
226 typedef std::equal_to
<key_type
> equality_function
;
228 template<typename Tl
>
231 typedef Tl allocator_type
;
232 typedef std::tr1::unordered_set
<key_type
, hash_function
, equality_function
, allocator_type
> type
;
235 typedef allocator_policies
<key_type
, Thread
> allocator_types
;
236 typedef typename
allocator_types::type allocator_typelist
;
237 typedef typename transform
<allocator_typelist
, container
>::type type
;
241 // A typelist of all associated container types, with each of the
242 // allocator policies.
243 template<typename Tp
, bool Thread
>
244 struct associative_containers
246 typedef Tp value_type
;
248 typedef typename maps
<value_type
, Thread
>::type map_typelist
;
249 typedef typename sets
<value_type
, Thread
>::type set_typelist
;
250 typedef typename unordered_maps
<value_type
, Thread
>::type unordered_map_typelist
;
251 typedef typename unordered_sets
<value_type
, Thread
>::type unordered_set_typelist
;
253 typedef typename append
<map_typelist
, unordered_map_typelist
>::type a1
;
254 typedef typename append
<set_typelist
, unordered_set_typelist
>::type a2
;
255 typedef typename append
<a1
, a2
>::type type
;
258 // A typelist of all integral types.
259 struct integral_types
263 typedef signed char a3
;
264 typedef unsigned char a4
;
266 typedef unsigned short a6
;
268 typedef unsigned int a8
;
270 typedef unsigned long a10
;
271 typedef long long a11
;
272 typedef unsigned long long a12
;
274 #ifdef __GXX_EXPERIMENTAL_CXX0X__
275 typedef char16_t a14
;
276 typedef char32_t a15
;
278 typedef node
<_GLIBCXX_TYPELIST_CHAIN15(a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
, a9
,
279 a10
, a11
, a12
, a13
, a14
, a15
)> type
;
281 typedef node
<_GLIBCXX_TYPELIST_CHAIN13(a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
, a9
,
282 a10
, a11
, a12
, a13
)> type
;
286 #ifdef __GXX_EXPERIMENTAL_CXX0X__
287 struct atomic_integrals_no_bool
289 typedef std::atomic_char a2
;
290 typedef std::atomic_schar a3
;
291 typedef std::atomic_uchar a4
;
292 typedef std::atomic_short a5
;
293 typedef std::atomic_ushort a6
;
294 typedef std::atomic_int a7
;
295 typedef std::atomic_uint a8
;
296 typedef std::atomic_long a9
;
297 typedef std::atomic_ulong a10
;
298 typedef std::atomic_llong a11
;
299 typedef std::atomic_ullong a12
;
300 typedef std::atomic_wchar_t a13
;
301 typedef std::atomic_char16_t a14
;
302 typedef std::atomic_char32_t a15
;
304 typedef node
<_GLIBCXX_TYPELIST_CHAIN14(a2
, a3
, a4
, a5
, a6
, a7
, a8
, a9
,
305 a10
, a11
, a12
, a13
, a14
, a15
)> type
;
308 struct atomic_integrals
310 typedef std::atomic_bool a1
;
311 typedef std::atomic_char a2
;
312 typedef std::atomic_schar a3
;
313 typedef std::atomic_uchar a4
;
314 typedef std::atomic_short a5
;
315 typedef std::atomic_ushort a6
;
316 typedef std::atomic_int a7
;
317 typedef std::atomic_uint a8
;
318 typedef std::atomic_long a9
;
319 typedef std::atomic_ulong a10
;
320 typedef std::atomic_llong a11
;
321 typedef std::atomic_ullong a12
;
322 typedef std::atomic_wchar_t a13
;
323 typedef std::atomic_char16_t a14
;
324 typedef std::atomic_char32_t a15
;
326 typedef node
<_GLIBCXX_TYPELIST_CHAIN15(a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
, a9
,
327 a10
, a11
, a12
, a13
, a14
, a15
)> type
;
331 template<typename Tp
>
334 typedef Tp value_type
;
335 typedef std::atomic
<value_type
> type
;
338 typedef transform
<integral_types::type
, atomics
>::type atomics_tl
;
342 struct has_increment_operators
344 template<typename _Tp
>
359 void (_Concept::*__x
)() __attribute__((unused
))
360 = &_Concept::__constraint
;
364 struct has_decrement_operators
366 template<typename _Tp
>
381 void (_Concept::*__x
)() __attribute__((unused
))
382 = &_Concept::__constraint
;
386 template<typename _Tp
>
398 template<typename _Tp
>
400 bitwise_assignment_operators()
409 // 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
411 template<typename _BitmTp
>
415 bitwise_operators
<_BitmTp
>();
416 bitwise_assignment_operators
<_BitmTp
>();
419 struct has_bitwise_operators
421 template<typename _Tp
>
437 void (_Concept::*__x
)() __attribute__((unused
))
438 = &_Concept::__constraint
;
442 // Generator to test standard layout
443 #ifdef __GXX_EXPERIMENTAL_CXX0X__
444 struct has_trivial_cons_dtor
446 template<typename _Tp
>
454 typedef std::has_trivial_default_constructor
<_Tp
> ctor_p
;
455 static_assert(ctor_p::value
, "default constructor not trivial");
457 typedef std::has_trivial_destructor
<_Tp
> dtor_p
;
458 static_assert(dtor_p::value
, "destructor not trivial");
462 void (_Concept::*__x
)() __attribute__((unused
))
463 = &_Concept::__constraint
;
467 struct standard_layout
469 template<typename _Tp
>
478 // typedef std::is_standard_layout<_Tp> standard_layout_p;
479 // static_assert(standard_layout_p::value, "not standard_layout");
481 typedef std::has_virtual_destructor
<_Tp
> ctor_p
;
482 static_assert(!ctor_p::value
, "has virtual destructor");
486 void (_Concept::*__x
)() __attribute__((unused
))
487 = &_Concept::__constraint
;
492 // Generator to test base class
493 struct has_required_base_class
495 template<typename _TBase
, typename _TDerived
>
503 const _TDerived
& obj
= __a
;
504 const _TBase
* base
__attribute__((unused
)) = &obj
;
510 void (_Concept::*__x
)() __attribute__((unused
))
511 = &_Concept::__constraint
;
515 // Generator to test assignment operator.
518 template<typename _Tp
>
531 void (_Concept::*__x
)() __attribute__((unused
))
532 = &_Concept::__constraint
;
536 // Generator to test default constructor.
537 struct default_constructible
539 template<typename _Tp
>
549 void (_Concept::*__x
)() __attribute__((unused
))
550 = &_Concept::__constraint
;
554 // Generator to test copy constructor.
555 struct copy_constructible
557 template<typename _Tp
>
569 void (_Concept::*__x
)() __attribute__((unused
))
570 = &_Concept::__constraint
;
574 // Generator to test direct initialization, single value constructor.
575 struct single_value_constructible
577 template<typename _Ttype
, typename _Tvalue
>
589 void (_Concept::*__x
)() __attribute__((unused
))
590 = &_Concept::__constraint
;
594 // Generator to test direct list initialization
595 #ifdef __GXX_EXPERIMENTAL_CXX0X__
596 struct direct_list_initializable
598 template<typename _Ttype
, typename _Tvalue
>
606 _Ttype __v1
{ }; // default ctor
607 _Ttype __v2
{ __a
}; // single-argument ctor
613 void (_Concept::*__x
)() __attribute__((unused
))
614 = &_Concept::__constraint
;
619 // Generator to test copy list initialization, aggregate initialization
620 struct copy_list_initializable
622 template<typename _Ttype
, typename _Tvalue
>
629 { _Ttype __v
= {__a
}; }
634 void (_Concept::*__x
)() __attribute__((unused
))
635 = &_Concept::__constraint
;
639 // Generator to test integral conversion operator
640 struct integral_convertable
642 template<typename _Ttype
, typename _Tvalue
>
655 bool test
__attribute__((unused
)) = true;
656 VERIFY( __v1
== __v0
);
660 void (_Concept::*__x
)() __attribute__((unused
))
661 = &_Concept::__constraint
;
665 // Generator to test integral assignment operator
666 struct integral_assignable
668 template<typename _Ttype
, typename _Tvalue
>
682 bool test
__attribute__((unused
)) = true;
683 VERIFY( __v1
== __vr
);
687 void (_Concept::*__x
)() __attribute__((unused
))
688 = &_Concept::__constraint
;
691 } // namespace __gnu_test