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
18int 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
28namespace ex = std::experimental::pmr;
29
30int main()
31{
32    using Alloc = NullAllocator<char>;
33    using R = ex::resource_adaptor<Alloc>;
34    AllocController P;
35    ex::resource_adaptor<Alloc> r(Alloc{P});
36    ex::memory_resource & m1 = r;
37
38    std::size_t maxSize = std::numeric_limits<std::size_t>::max()
39                            - alignof(std::max_align_t);
40
41    m1.deallocate(nullptr, maxSize);
42    assert(AssertCount == 0);
43    m1.deallocate(nullptr, maxSize + 1);
44    assert(AssertCount >= 1);
45}
46