|
18 | 18 | // typedef ptrdiff_t difference_type;
|
19 | 19 | // typedef T value_type;
|
20 | 20 | //
|
| 21 | +// typedef T* pointer; // deprecated in C++17, removed in C++20 |
| 22 | +// typedef T const* const_pointer; // deprecated in C++17, removed in C++20 |
| 23 | +// typedef T& reference; // deprecated in C++17, removed in C++20 |
| 24 | +// typedef T const& const_reference; // deprecated in C++17, removed in C++20 |
| 25 | +// template< class U > struct rebind { typedef allocator<U> other; }; // deprecated in C++17, removed in C++20 |
| 26 | +// |
21 | 27 | // typedef true_type propagate_on_container_move_assignment;
|
22 | 28 | // typedef true_type is_always_equal;
|
23 | 29 | // ...
|
24 | 30 | // };
|
25 | 31 |
|
| 32 | +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 33 | + |
26 | 34 | #include <memory>
|
27 | 35 | #include <type_traits>
|
28 | 36 | #include <cstddef>
|
29 | 37 |
|
30 | 38 | #include "test_macros.h"
|
31 | 39 |
|
32 |
| -template <typename T, typename U> |
33 |
| -TEST_CONSTEXPR_CXX20 bool test() |
34 |
| -{ |
35 |
| - static_assert((std::is_same<typename std::allocator<T>::size_type, std::size_t>::value), ""); |
36 |
| - static_assert((std::is_same<typename std::allocator<T>::difference_type, std::ptrdiff_t>::value), ""); |
37 |
| - static_assert((std::is_same<typename std::allocator<T>::value_type, T>::value), ""); |
38 |
| - static_assert((std::is_same<typename std::allocator<T>::propagate_on_container_move_assignment, std::true_type>::value), ""); |
39 |
| - static_assert((std::is_same<typename std::allocator<T>::is_always_equal, std::true_type>::value), ""); |
| 40 | +struct U; |
40 | 41 |
|
41 |
| - std::allocator<T> a; |
42 |
| - std::allocator<T> a2 = a; |
43 |
| - a2 = a; |
44 |
| - std::allocator<U> a3 = a2; |
45 |
| - (void)a3; |
| 42 | +template <typename T> |
| 43 | +void test() { |
| 44 | + typedef std::allocator<T> Alloc; |
| 45 | + static_assert((std::is_same<typename Alloc::size_type, std::size_t>::value), ""); |
| 46 | + static_assert((std::is_same<typename Alloc::difference_type, std::ptrdiff_t>::value), ""); |
| 47 | + static_assert((std::is_same<typename Alloc::value_type, T>::value), ""); |
| 48 | + static_assert((std::is_same<typename Alloc::propagate_on_container_move_assignment, std::true_type>::value), ""); |
| 49 | + static_assert((std::is_same<typename Alloc::is_always_equal, std::true_type>::value), ""); |
46 | 50 |
|
47 |
| - return true; |
| 51 | +#if TEST_STD_VER <= 17 |
| 52 | + static_assert((std::is_same<typename Alloc::pointer, T*>::value), ""); |
| 53 | + static_assert((std::is_same<typename Alloc::const_pointer, T const*>::value), ""); |
| 54 | + static_assert((std::is_same<typename Alloc::reference, T&>::value), ""); |
| 55 | + static_assert((std::is_same<typename Alloc::const_reference, T const&>::value), ""); |
| 56 | + static_assert((std::is_same<typename Alloc::template rebind<U>::other, std::allocator<U> >::value), ""); |
| 57 | +#endif |
48 | 58 | }
|
49 | 59 |
|
50 |
| -int main(int, char**) |
51 |
| -{ |
52 |
| - test<char, int>(); |
53 |
| -#ifdef _LIBCPP_VERSION // extension |
54 |
| - test<char const, int const>(); |
55 |
| -#endif // _LIBCPP_VERSION |
56 |
| - |
57 |
| -#if TEST_STD_VER > 17 |
58 |
| - static_assert(test<char, int>()); |
59 |
| -#ifdef _LIBCPP_VERSION // extension |
60 |
| - static_assert(test<char const, int const>()); |
61 |
| -#endif // _LIBCPP_VERSION |
| 60 | +int main(int, char**) { |
| 61 | + test<char>(); |
| 62 | +#ifdef _LIBCPP_VERSION |
| 63 | + test<char const>(); // extension |
62 | 64 | #endif
|
63 | 65 | return 0;
|
64 | 66 | }
|
0 commit comments