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#include "count_new.h"
21
22int main(int, char**) {
23 // Constructing a monotonic_buffer_resource should not cause allocations
24 // by itself; the resource should wait to allocate until an allocation is
25 // requested.
26
27 globalMemCounter.reset();
28 std::pmr::set_default_resource(std::pmr::new_delete_resource());
29
30 std::pmr::monotonic_buffer_resource r1;
31 assert(globalMemCounter.checkNewCalledEq(0));
32
33 std::pmr::monotonic_buffer_resource r2(1024);
34 assert(globalMemCounter.checkNewCalledEq(0));
35
36 std::pmr::monotonic_buffer_resource r3(1024, std::pmr::new_delete_resource());
37 assert(globalMemCounter.checkNewCalledEq(0));
38
39 return 0;
40}
41

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/without_buffer.pass.cpp