1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03, c++11, c++14
10 // REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
11
12 // <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 #include <memory_resource>
21 #include <type_traits>
22 #include <cassert>
23
24 #include "check_assertion.h"
25 #include "test_std_memory_resource.h"
26
main(int,char **)27 int main(int, char**) {
28 using Alloc = std::pmr::polymorphic_allocator<int>;
29 using Traits = std::allocator_traits<Alloc>;
30 NullResource R;
31 Alloc a(&R);
32 const std::size_t maxSize = Traits::max_size(a);
33
34 a.deallocate(nullptr, maxSize); // no assertion
35 TEST_LIBCPP_ASSERT_FAILURE(a.deallocate(nullptr, maxSize + 1), "deallocate called for size which exceeds max_size()");
36
37 return 0;
38 }
39