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 monotonic_buffer_resource |
16 | |
17 | #include <memory_resource> |
18 | #include <cassert> |
19 | |
20 | int main(int, char**) { |
21 | std::pmr::memory_resource* expected = std::pmr::null_memory_resource(); |
22 | std::pmr::set_default_resource(expected); |
23 | { |
24 | char buffer[16]; |
25 | std::pmr::monotonic_buffer_resource r1; |
26 | std::pmr::monotonic_buffer_resource r2(16); |
27 | std::pmr::monotonic_buffer_resource r3(buffer, sizeof buffer); |
28 | assert(r1.upstream_resource() == expected); |
29 | assert(r2.upstream_resource() == expected); |
30 | assert(r3.upstream_resource() == expected); |
31 | } |
32 | |
33 | expected = std::pmr::new_delete_resource(); |
34 | std::pmr::set_default_resource(expected); |
35 | { |
36 | char buffer[16]; |
37 | std::pmr::monotonic_buffer_resource r1; |
38 | std::pmr::monotonic_buffer_resource r2(16); |
39 | std::pmr::monotonic_buffer_resource r3(buffer, sizeof buffer); |
40 | assert(r1.upstream_resource() == expected); |
41 | assert(r2.upstream_resource() == expected); |
42 | assert(r3.upstream_resource() == expected); |
43 | } |
44 | |
45 | return 0; |
46 | } |
47 |