1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include <type_traits>
15 #include "test_macros.h"
19 // template <class Alloc>
20 // struct allocator_traits
22 // typedef Alloc allocator_type;
23 // typedef typename allocator_type::value_type
26 // typedef Alloc::pointer | value_type* pointer;
27 // typedef Alloc::const_pointer
28 // | pointer_traits<pointer>::rebind<const value_type>
30 // typedef Alloc::void_pointer
31 // | pointer_traits<pointer>::rebind<void>
33 // typedef Alloc::const_void_pointer
34 // | pointer_traits<pointer>::rebind<const void>
35 // const_void_pointer;
37 template <typename Alloc
>
40 typename
std::allocator_traits
<Alloc
>::pointer vp
;
41 typename
std::allocator_traits
<Alloc
>::const_pointer cvp
;
43 ((void)vp
); // Prevent unused warning
44 ((void)cvp
); // Prevent unused warning
46 static_assert(std::is_same
<bool, decltype( vp
== vp
)>::value
, "");
47 static_assert(std::is_same
<bool, decltype( vp
!= vp
)>::value
, "");
48 static_assert(std::is_same
<bool, decltype( vp
> vp
)>::value
, "");
49 static_assert(std::is_same
<bool, decltype( vp
>= vp
)>::value
, "");
50 static_assert(std::is_same
<bool, decltype( vp
< vp
)>::value
, "");
51 static_assert(std::is_same
<bool, decltype( vp
<= vp
)>::value
, "");
53 static_assert(std::is_same
<bool, decltype( vp
== cvp
)>::value
, "");
54 static_assert(std::is_same
<bool, decltype(cvp
== vp
)>::value
, "");
55 static_assert(std::is_same
<bool, decltype( vp
!= cvp
)>::value
, "");
56 static_assert(std::is_same
<bool, decltype(cvp
!= vp
)>::value
, "");
57 static_assert(std::is_same
<bool, decltype( vp
> cvp
)>::value
, "");
58 static_assert(std::is_same
<bool, decltype(cvp
> vp
)>::value
, "");
59 static_assert(std::is_same
<bool, decltype( vp
>= cvp
)>::value
, "");
60 static_assert(std::is_same
<bool, decltype(cvp
>= vp
)>::value
, "");
61 static_assert(std::is_same
<bool, decltype( vp
< cvp
)>::value
, "");
62 static_assert(std::is_same
<bool, decltype(cvp
< vp
)>::value
, "");
63 static_assert(std::is_same
<bool, decltype( vp
<= cvp
)>::value
, "");
64 static_assert(std::is_same
<bool, decltype(cvp
<= vp
)>::value
, "");
66 static_assert(std::is_same
<bool, decltype(cvp
== cvp
)>::value
, "");
67 static_assert(std::is_same
<bool, decltype(cvp
!= cvp
)>::value
, "");
68 static_assert(std::is_same
<bool, decltype(cvp
> cvp
)>::value
, "");
69 static_assert(std::is_same
<bool, decltype(cvp
>= cvp
)>::value
, "");
70 static_assert(std::is_same
<bool, decltype(cvp
< cvp
)>::value
, "");
71 static_assert(std::is_same
<bool, decltype(cvp
<= cvp
)>::value
, "");
74 template <typename Alloc
>
75 void test_void_pointer()
77 typename
std::allocator_traits
<Alloc
>::void_pointer vp
;
78 typename
std::allocator_traits
<Alloc
>::const_void_pointer cvp
;
80 ((void)vp
); // Prevent unused warning
81 ((void)cvp
); // Prevent unused warning
83 static_assert(std::is_same
<bool, decltype( vp
== vp
)>::value
, "");
84 static_assert(std::is_same
<bool, decltype( vp
!= vp
)>::value
, "");
85 static_assert(std::is_same
<bool, decltype( vp
> vp
)>::value
, "");
86 static_assert(std::is_same
<bool, decltype( vp
>= vp
)>::value
, "");
87 static_assert(std::is_same
<bool, decltype( vp
< vp
)>::value
, "");
88 static_assert(std::is_same
<bool, decltype( vp
<= vp
)>::value
, "");
90 static_assert(std::is_same
<bool, decltype( vp
== cvp
)>::value
, "");
91 static_assert(std::is_same
<bool, decltype(cvp
== vp
)>::value
, "");
92 static_assert(std::is_same
<bool, decltype( vp
!= cvp
)>::value
, "");
93 static_assert(std::is_same
<bool, decltype(cvp
!= vp
)>::value
, "");
94 static_assert(std::is_same
<bool, decltype( vp
> cvp
)>::value
, "");
95 static_assert(std::is_same
<bool, decltype(cvp
> vp
)>::value
, "");
96 static_assert(std::is_same
<bool, decltype( vp
>= cvp
)>::value
, "");
97 static_assert(std::is_same
<bool, decltype(cvp
>= vp
)>::value
, "");
98 static_assert(std::is_same
<bool, decltype( vp
< cvp
)>::value
, "");
99 static_assert(std::is_same
<bool, decltype(cvp
< vp
)>::value
, "");
100 static_assert(std::is_same
<bool, decltype( vp
<= cvp
)>::value
, "");
101 static_assert(std::is_same
<bool, decltype(cvp
<= vp
)>::value
, "");
103 static_assert(std::is_same
<bool, decltype(cvp
== cvp
)>::value
, "");
104 static_assert(std::is_same
<bool, decltype(cvp
!= cvp
)>::value
, "");
105 static_assert(std::is_same
<bool, decltype(cvp
> cvp
)>::value
, "");
106 static_assert(std::is_same
<bool, decltype(cvp
>= cvp
)>::value
, "");
107 static_assert(std::is_same
<bool, decltype(cvp
< cvp
)>::value
, "");
108 static_assert(std::is_same
<bool, decltype(cvp
<= cvp
)>::value
, "");
111 struct Foo
{ int x
; };
113 int main(int, char**)
115 test_pointer
<std::allocator
<char>> ();
116 test_pointer
<std::allocator
<int>> ();
117 test_pointer
<std::allocator
<Foo
>> ();
119 test_void_pointer
<std::allocator
<char>> ();
120 test_void_pointer
<std::allocator
<int>> ();
121 test_void_pointer
<std::allocator
<Foo
>> ();