[libcxx-commits] [libcxx] [libc++] Update the status for lwg-3120 (PR #116772)
Peng Xie via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 10 01:35:04 PST 2025
================
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: availability-pmr-missing
+
+// <memory_resource>
+
+// class monotonic_buffer_resource
+
+#include <memory_resource>
+#include <cassert>
+#include <tuple> // std::ignore
+
+#include "count_new.h"
+#include "test_macros.h"
+
+int main(int, char**) {
+ {
+ // https://cplusplus.github.io/LWG/issue3120
+ {
+ // when init given a next buffer size, after release(), reset/not change next buffer size from initial state
+ constexpr auto expect_next_buffer_size{512ULL};
+ std::pmr::monotonic_buffer_resource mr{nullptr, expect_next_buffer_size, std::pmr::new_delete_resource()};
+
+ for (auto i{0}; i < 100; ++i) {
+ std::ignore = mr.allocate(1);
+ mr.release();
+ ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeGe(expect_next_buffer_size));
+ }
+ }
+ {
+ // Given
+ // when init given a buffer, after release(), initial ptr will reset to it's initial state
+ constexpr auto buffer_size{512ULL};
+ char buffer[buffer_size];
+ std::pmr::monotonic_buffer_resource mr{buffer, buffer_size, std::pmr::null_memory_resource()};
+
+ auto expect_mem_start = mr.allocate(1);
+ for (auto i{0}; i < 100; ++i) {
+ mr.release();
+ auto ths_mem_start = mr.allocate(1);
+ assert(expect_mem_start == ths_mem_start);
+ }
+ }
+ }
+}
----------------
love1angel wrote:
done. thanks, could you review it again?
https://github.com/llvm/llvm-project/pull/116772
More information about the libcxx-commits
mailing list