]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do compile { target c++11 } } |
7cc9022f | 2 | // { dg-require-effective-target hosted } |
1b5dc776 | 3 | |
a945c346 | 4 | // Copyright (C) 2012-2024 Free Software Foundation, Inc. |
1b5dc776 JW |
5 | // |
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) | |
10 | // any later version. | |
11 | ||
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. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License | |
18 | // along with this library; see the file COPYING3. If not see | |
19 | // <http://www.gnu.org/licenses/>. | |
20 | ||
21 | ||
22 | #include <memory> | |
23 | #include <type_traits> | |
24 | ||
25 | // Check std::allocator for required typedefs. | |
26 | ||
27 | using std::is_same; | |
28 | using std::allocator; | |
29 | ||
30 | static_assert( is_same<allocator<int>::size_type, std::size_t>::value, | |
31 | "size_type" ); | |
32 | static_assert( is_same<allocator<int>::difference_type, std::ptrdiff_t>::value, | |
33 | "difference_type" ); | |
2cae56bd | 34 | #if __cplusplus <= 201703L |
1b5dc776 JW |
35 | static_assert( is_same<allocator<int>::pointer, int*>::value, |
36 | "pointer" ); | |
37 | static_assert( is_same<allocator<int>::const_pointer, const int*>::value, | |
38 | "const_pointer" ); | |
39 | static_assert( is_same<allocator<int>::reference, int&>::value, | |
40 | "reference" ); | |
41 | static_assert( is_same<allocator<int>::const_reference, const int&>::value, | |
42 | "const_reference" ); | |
2cae56bd | 43 | #endif |
1b5dc776 JW |
44 | static_assert( is_same<allocator<int>::value_type, int>::value, |
45 | "value_type" ); | |
46 | ||
2cae56bd | 47 | #if __cplusplus <= 201703L |
0e8330d9 JW |
48 | static_assert( is_same<allocator<int>::rebind<char>::other, |
49 | allocator<char>>::value, | |
50 | "rebind::other" ); | |
2cae56bd | 51 | #endif |
0e8330d9 JW |
52 | |
53 | static_assert( is_same<allocator<int>::propagate_on_container_move_assignment, | |
54 | std::true_type>::value, | |
55 | "propagate_on_container_move_assignment" ); | |
46942c81 | 56 | |
5bfcfe30 JW |
57 | using IAE = allocator<int>::is_always_equal; // { dg-warning "deprecated" "" { target c++20 } } |
58 | static_assert( is_same<IAE, std::true_type>::value, "is_always_equal" ); | |
59 | ||
60 | ||
61 | // Test required typedefs for allocator<void> specialization. | |
62 | static_assert( is_same<allocator<void>::value_type, void>::value, | |
63 | "void value_type" ); | |
64 | #if __cplusplus <= 201703L | |
65 | static_assert( is_same<allocator<void>::pointer, void*>::value, | |
66 | "void pointer" ); | |
67 | static_assert( is_same<allocator<void>::const_pointer, const void*>::value, | |
68 | "void const_pointer" ); | |
69 | static_assert( is_same<allocator<void>::rebind<char>::other, | |
70 | allocator<char>>::value, | |
71 | "void rebind::other" ); | |
72 | #else | |
73 | // Since C++20 allocator<void> uses the primary template, so has the same types. | |
74 | static_assert( is_same<allocator<void>::propagate_on_container_move_assignment, | |
75 | std::true_type>::value, | |
76 | "propagate_on_container_move_assignment" ); | |
77 | ||
78 | using VIAE = allocator<void>::is_always_equal; // { dg-warning "deprecated" "" { target c++20 } } | |
79 | static_assert( is_same<VIAE, std::true_type>::value, "is_always_equal" ); | |
80 | #endif |