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// TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11// UNSUPPORTED: availability-pmr-missing
12
13// <memory_resource>
14
15// class unsynchronized_pool_resource
16
17#include <memory_resource>
18#include <cassert>
19
20int main(int, char**) {
21 std::pmr::memory_resource* expected = std::pmr::null_memory_resource();
22 std::pmr::set_default_resource(expected);
23 {
24 std::pmr::pool_options opts{.max_blocks_per_chunk: 0, .largest_required_pool_block: 0};
25 std::pmr::unsynchronized_pool_resource r1;
26 std::pmr::unsynchronized_pool_resource r2(opts);
27 assert(r1.upstream_resource() == expected);
28 assert(r2.upstream_resource() == expected);
29 }
30
31 expected = std::pmr::new_delete_resource();
32 std::pmr::set_default_resource(expected);
33 {
34 std::pmr::pool_options opts{.max_blocks_per_chunk: 1024, .largest_required_pool_block: 2048};
35 std::pmr::unsynchronized_pool_resource r1;
36 std::pmr::unsynchronized_pool_resource r2(opts);
37 assert(r1.upstream_resource() == expected);
38 assert(r2.upstream_resource() == expected);
39 }
40
41 return 0;
42}
43

source code of libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.ctor/unsync_with_default_resource.pass.cpp