| 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, c++11, c++14 |
| 10 | // TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed |
| 11 | // UNSUPPORTED: availability-pmr-missing |
| 12 | |
| 13 | // <memory_resource> |
| 14 | |
| 15 | // template <class T> class polymorphic_allocator |
| 16 | |
| 17 | // template <class U> |
| 18 | // polymorphic_allocator<T>::polymorphic_allocator(polymorphic_allocator<U> const &); |
| 19 | |
| 20 | #include <memory_resource> |
| 21 | #include <cassert> |
| 22 | #include <type_traits> |
| 23 | #include <utility> |
| 24 | |
| 25 | int main(int, char**) { |
| 26 | typedef std::pmr::polymorphic_allocator<void> A1; |
| 27 | typedef std::pmr::polymorphic_allocator<char> A2; |
| 28 | { // Test that the conversion is implicit and noexcept. |
| 29 | static_assert(std::is_convertible<A1 const&, A2>::value, "" ); |
| 30 | static_assert(std::is_convertible<A2 const&, A1>::value, "" ); |
| 31 | static_assert(std::is_nothrow_constructible<A1, A2 const&>::value, "" ); |
| 32 | static_assert(std::is_nothrow_constructible<A2, A1 const&>::value, "" ); |
| 33 | } |
| 34 | // copy other type |
| 35 | { |
| 36 | A1 const a((std::pmr::memory_resource*)42); |
| 37 | A2 const a2(a); |
| 38 | assert(a.resource() == a2.resource()); |
| 39 | assert(a2.resource() == (std::pmr::memory_resource*)42); |
| 40 | } |
| 41 | { |
| 42 | A1 a((std::pmr::memory_resource*)42); |
| 43 | A2 const a2(std::move(a)); |
| 44 | assert(a.resource() == a2.resource()); |
| 45 | assert(a2.resource() == (std::pmr::memory_resource*)42); |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |