| 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 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03 |
| 10 | |
| 11 | // <memory> |
| 12 | |
| 13 | // template <class OuterAlloc, class... InnerAllocs> |
| 14 | // class scoped_allocator_adaptor |
| 15 | |
| 16 | // typedef see below is_always_equal; |
| 17 | |
| 18 | #include <scoped_allocator> |
| 19 | #include <type_traits> |
| 20 | |
| 21 | #include "test_macros.h" |
| 22 | #include "allocators.h" |
| 23 | #include "min_allocator.h" |
| 24 | |
| 25 | int main(int, char**) { |
| 26 | // sanity checks |
| 27 | static_assert((std::is_same< std::allocator_traits<A1<int>>::is_always_equal, std::false_type>::value), "" ); |
| 28 | |
| 29 | static_assert((std::is_same< std::allocator_traits<min_allocator<int>>::is_always_equal, std::true_type>::value), "" ); |
| 30 | |
| 31 | // wrapping one allocator |
| 32 | static_assert((std::is_same< std::scoped_allocator_adaptor<A1<int>>::is_always_equal, |
| 33 | std::allocator_traits<A1<int>>::is_always_equal >::value), |
| 34 | "" ); |
| 35 | |
| 36 | // wrapping one allocator |
| 37 | static_assert((std::is_same< std::scoped_allocator_adaptor<min_allocator<int>>::is_always_equal, |
| 38 | std::allocator_traits<min_allocator<int>>::is_always_equal >::value), |
| 39 | "" ); |
| 40 | |
| 41 | // wrapping two allocators (check the values instead of the types) |
| 42 | static_assert((std::scoped_allocator_adaptor<A1<int>, A2<int>>::is_always_equal::value == |
| 43 | (std::allocator_traits<A1<int>>::is_always_equal::value && |
| 44 | std::allocator_traits<A2<int>>::is_always_equal::value)), |
| 45 | "" ); |
| 46 | |
| 47 | // wrapping two allocators (check the values instead of the types) |
| 48 | static_assert((std::scoped_allocator_adaptor<A1<int>, min_allocator<int>>::is_always_equal::value == |
| 49 | (std::allocator_traits<A1<int>>::is_always_equal::value && |
| 50 | std::allocator_traits<min_allocator<int>>::is_always_equal::value)), |
| 51 | "" ); |
| 52 | |
| 53 | // wrapping three allocators (check the values instead of the types) |
| 54 | static_assert((std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::is_always_equal::value == |
| 55 | (std::allocator_traits<A1<int>>::is_always_equal::value && |
| 56 | std::allocator_traits<A2<int>>::is_always_equal::value && |
| 57 | std::allocator_traits<A3<int>>::is_always_equal::value)), |
| 58 | "" ); |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |