| 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 | // test_memory_resource requires RTTI for dynamic_cast |
| 14 | // UNSUPPORTED: no-rtti |
| 15 | |
| 16 | // <memory_resource> |
| 17 | |
| 18 | // template <class T> class polymorphic_allocator |
| 19 | |
| 20 | // polymorphic_allocator<T>::polymorphic_allocator(memory_resource *) |
| 21 | |
| 22 | #include <memory_resource> |
| 23 | #include <type_traits> |
| 24 | #include <cassert> |
| 25 | |
| 26 | #include "test_std_memory_resource.h" |
| 27 | |
| 28 | int main(int, char**) { |
| 29 | { |
| 30 | typedef std::pmr::polymorphic_allocator<void> A; |
| 31 | static_assert(std::is_convertible_v<decltype(nullptr), A>); |
| 32 | static_assert(std::is_convertible_v<std::pmr::memory_resource*, A>); |
| 33 | } |
| 34 | { |
| 35 | typedef std::pmr::polymorphic_allocator<void> A; |
| 36 | TestResource R; |
| 37 | A const a(&R); |
| 38 | assert(a.resource() == &R); |
| 39 | } |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |