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// REQUIRES: c++experimental 11// UNSUPPORTED: c++98, c++03 12 13// <experimental/memory_resource> 14 15// template <class T> class polymorphic_allocator 16 17// polymorphic_allocator<T>::polymorphic_allocator() noexcept 18 19#include <experimental/memory_resource> 20#include <type_traits> 21#include <cassert> 22 23#include "test_memory_resource.hpp" 24 25namespace ex = std::experimental::pmr; 26 27int main() 28{ 29 { 30 static_assert( 31 std::is_nothrow_default_constructible<ex::polymorphic_allocator<void>>::value 32 , "Must me nothrow default constructible" 33 ); 34 } 35 { 36 // test that the allocator gets its resource from get_default_resource 37 TestResource R1(42); 38 ex::set_default_resource(&R1); 39 40 typedef ex::polymorphic_allocator<void> A; 41 A const a; 42 assert(a.resource() == &R1); 43 44 ex::set_default_resource(nullptr); 45 A const a2; 46 assert(a.resource() == &R1); 47 assert(a2.resource() == ex::new_delete_resource()); 48 } 49} 50