| 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 | // friend bool operator==(const polymorphic_allocator& a, |
| 18 | // const polymorphic_allocator& b) noexcept |
| 19 | |
| 20 | #include <memory_resource> |
| 21 | #include <cassert> |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "test_macros.h" |
| 25 | |
| 26 | int main(int, char**) { |
| 27 | std::pmr::unsynchronized_pool_resource a; |
| 28 | std::pmr::vector<int> vec(&a); |
| 29 | |
| 30 | assert(vec.get_allocator() == &a); |
| 31 | static_assert(noexcept(vec.get_allocator() == &a)); |
| 32 | |
| 33 | // LWG3683 added operator== after C++20. In C++20 operator!= is generated by |
| 34 | // the compiler. Libc++ adds operator!= in C++17 as an extension. MSVC STL |
| 35 | // and libstdc++ have done the same so test this extension unconditionally. |
| 36 | std::pmr::unsynchronized_pool_resource b; |
| 37 | |
| 38 | assert(vec.get_allocator() != &b); |
| 39 | static_assert(noexcept(vec.get_allocator() != &b)); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |