]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / allocator / requirements / typedefs.cc
CommitLineData
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
27using std::is_same;
28using std::allocator;
29
30static_assert( is_same<allocator<int>::size_type, std::size_t>::value,
31 "size_type" );
32static_assert( is_same<allocator<int>::difference_type, std::ptrdiff_t>::value,
33 "difference_type" );
2cae56bd 34#if __cplusplus <= 201703L
1b5dc776
JW
35static_assert( is_same<allocator<int>::pointer, int*>::value,
36 "pointer" );
37static_assert( is_same<allocator<int>::const_pointer, const int*>::value,
38 "const_pointer" );
39static_assert( is_same<allocator<int>::reference, int&>::value,
40 "reference" );
41static_assert( is_same<allocator<int>::const_reference, const int&>::value,
42 "const_reference" );
2cae56bd 43#endif
1b5dc776
JW
44static_assert( is_same<allocator<int>::value_type, int>::value,
45 "value_type" );
46
2cae56bd 47#if __cplusplus <= 201703L
0e8330d9
JW
48static_assert( is_same<allocator<int>::rebind<char>::other,
49 allocator<char>>::value,
50 "rebind::other" );
2cae56bd 51#endif
0e8330d9
JW
52
53static_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
57using IAE = allocator<int>::is_always_equal; // { dg-warning "deprecated" "" { target c++20 } }
58static_assert( is_same<IAE, std::true_type>::value, "is_always_equal" );
59
60
61// Test required typedefs for allocator<void> specialization.
62static_assert( is_same<allocator<void>::value_type, void>::value,
63 "void value_type" );
64#if __cplusplus <= 201703L
65static_assert( is_same<allocator<void>::pointer, void*>::value,
66 "void pointer" );
67static_assert( is_same<allocator<void>::const_pointer, const void*>::value,
68 "void const_pointer" );
69static_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.
74static_assert( is_same<allocator<void>::propagate_on_container_move_assignment,
75 std::true_type>::value,
76 "propagate_on_container_move_assignment" );
77
78using VIAE = allocator<void>::is_always_equal; // { dg-warning "deprecated" "" { target c++20 } }
79static_assert( is_same<VIAE, std::true_type>::value, "is_always_equal" );
80#endif