1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03 11 12 // <experimental/memory_resource> 13 14 // template <class T> class polymorphic_allocator 15 16 // template <class U> 17 // polymorphic_allocator<T>::polymorphic_allocator(polymorphic_allocator<U> const &); 18 19 20 #include <experimental/memory_resource> 21 #include <type_traits> 22 #include <cassert> 23 24 namespace ex = std::experimental::pmr; 25 26 int main() 27 { 28 typedef ex::polymorphic_allocator<void> A1; 29 typedef ex::polymorphic_allocator<char> A2; 30 { // Test that the conversion is implicit and noexcept. 31 static_assert( 32 std::is_convertible<A1 const &, A2>::value, "" 33 ); 34 static_assert( 35 std::is_convertible<A2 const &, A1>::value, "" 36 ); 37 static_assert( 38 std::is_nothrow_constructible<A1, A2 const &>::value, "" 39 ); 40 static_assert( 41 std::is_nothrow_constructible<A2, A1 const &>::value, "" 42 ); 43 } 44 // copy other type 45 { 46 A1 const a((ex::memory_resource*)42); 47 A2 const a2(a); 48 assert(a.resource() == a2.resource()); 49 assert(a2.resource() == (ex::memory_resource*)42); 50 } 51 { 52 A1 a((ex::memory_resource*)42); 53 A2 const a2(std::move(a)); 54 assert(a.resource() == a2.resource()); 55 assert(a2.resource() == (ex::memory_resource*)42); 56 } 57 } 58