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 // T* polymorphic_allocator<T>::deallocate(T*, size_t size) 17 18 int AssertCount = 0; 19 20 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++) 21 #define _LIBCPP_DEBUG 0 22 #include <experimental/memory_resource> 23 #include <type_traits> 24 #include <cassert> 25 26 #include "test_memory_resource.hpp" 27 28 namespace ex = std::experimental::pmr; 29 30 int main() 31 { 32 using Alloc = ex::polymorphic_allocator<int>; 33 using Traits = std::allocator_traits<Alloc>; 34 NullResource R; 35 Alloc a(&R); 36 const std::size_t maxSize = Traits::max_size(a); 37 38 a.deallocate(nullptr, maxSize); 39 assert(AssertCount == 0); 40 a.deallocate(nullptr, maxSize + 1); 41 assert(AssertCount == 1); 42 } 43