[flang][OpenMP] Use range-for to iterate over SymbolSourceMap, NFC
[llvm-project.git] / libcxx / test / std / utilities / memory / default.allocator / allocator_pointers.pass.cpp
blobcb3ec8857a6feb5753d9bb4f7d74017c569350aa
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 #include <memory>
12 #include <cassert>
13 #include <type_traits>
15 #include "test_macros.h"
17 // <memory>
19 // template <class Alloc>
20 // struct allocator_traits
21 // {
22 // typedef Alloc allocator_type;
23 // typedef typename allocator_type::value_type
24 // value_type;
26 // typedef Alloc::pointer | value_type* pointer;
27 // typedef Alloc::const_pointer
28 // | pointer_traits<pointer>::rebind<const value_type>
29 // const_pointer;
30 // typedef Alloc::void_pointer
31 // | pointer_traits<pointer>::rebind<void>
32 // void_pointer;
33 // typedef Alloc::const_void_pointer
34 // | pointer_traits<pointer>::rebind<const void>
35 // const_void_pointer;
37 template <typename Alloc>
38 void test_pointer()
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>> ();
123 return 0;