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 Alloc> class resource_adaptor_imp; 15 16 // bool do_is_equal(memory_resource const &) const noexcept; 17 18 #include <experimental/memory_resource> 19 #include <type_traits> 20 #include <memory> 21 #include <cassert> 22 #include "test_memory_resource.hpp" 23 24 using std::size_t; 25 namespace ex = std::experimental::pmr; 26 main()27int main() 28 { 29 30 typedef CountingAllocator<char> Alloc1; 31 typedef CountingAllocator<int> RAlloc1; 32 typedef ex::resource_adaptor<Alloc1> R1; 33 typedef ex::resource_adaptor<RAlloc1> RR1; 34 static_assert(std::is_same<R1, RR1>::value, ""); 35 36 typedef std::allocator<char> Alloc2; 37 typedef ex::resource_adaptor<Alloc2> R2; 38 static_assert(!std::is_same<R1, R2>::value, ""); 39 40 // equal same type 41 { 42 AllocController C; 43 Alloc1 a1(C); 44 R1 const r1(a1); 45 ex::memory_resource const & m1 = r1; 46 47 Alloc1 a2(C); 48 R1 const r2(a2); 49 ex::memory_resource const & m2 = r2; 50 51 assert(m1.is_equal(m2)); 52 assert(m2.is_equal(m1)); 53 } 54 // not equal same type 55 { 56 AllocController C; 57 Alloc1 a1(C); 58 R1 const r1(a1); 59 ex::memory_resource const & m1 = r1; 60 61 AllocController C2; 62 Alloc1 a2(C2); 63 R1 const r2(a2); 64 ex::memory_resource const & m2 = r2; 65 66 assert(!m1.is_equal(m2)); 67 assert(!m2.is_equal(m1)); 68 } 69 // different allocator types 70 { 71 AllocController C; 72 Alloc1 a1(C); 73 R1 const r1(a1); 74 ex::memory_resource const & m1 = r1; 75 76 Alloc2 a2; 77 R2 const r2(a2); 78 ex::memory_resource const & m2 = r2; 79 80 assert(!m1.is_equal(m2)); 81 assert(!m2.is_equal(m1)); 82 } 83 } 84