1 // { dg-do compile { target c++11 } }
2 // { dg-require-effective-target hosted }
4 // Copyright (C) 2012-2024 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
18 // along with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
23 #include <type_traits>
25 // Check std::allocator for required typedefs.
30 static_assert( is_same
<allocator
<int>::size_type
, std::size_t>::value
,
32 static_assert( is_same
<allocator
<int>::difference_type
, std::ptrdiff_t>::value
,
34 #if __cplusplus <= 201703L
35 static_assert( is_same
<allocator
<int>::pointer
, int*>::value
,
37 static_assert( is_same
<allocator
<int>::const_pointer
, const int*>::value
,
39 static_assert( is_same
<allocator
<int>::reference
, int&>::value
,
41 static_assert( is_same
<allocator
<int>::const_reference
, const int&>::value
,
44 static_assert( is_same
<allocator
<int>::value_type
, int>::value
,
47 #if __cplusplus <= 201703L
48 static_assert( is_same
<allocator
<int>::rebind
<char>::other
,
49 allocator
<char>>::value
,
53 static_assert( is_same
<allocator
<int>::propagate_on_container_move_assignment
,
54 std::true_type
>::value
,
55 "propagate_on_container_move_assignment" );
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" );
61 // Test required typedefs for allocator<void> specialization.
62 static_assert( is_same
<allocator
<void>::value_type
, void>::value
,
64 #if __cplusplus <= 201703L
65 static_assert( is_same
<allocator
<void>::pointer
, void*>::value
,
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" );
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" );
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" );