[libcxx-commits] [libcxx] [libc++] Update the status for lwg-3120 (PR #116772)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 18 03:31:18 PST 2025


================
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++17
+// UNSUPPORTED: availability-pmr-missing
+
+// <memory_resource>
+
+// class monotonic_buffer_resource
+
+#include <memory_resource>
+#include <cassert>
+
+#include "count_new.h"
+#include "test_macros.h"
+
+int main(int, char**) {
+  {
+    {
+      // when init given a next buffer size, after release(), reset/not change next buffer size from initial state
+      constexpr size_t expect_next_buffer_size = 512;
+      std::pmr::monotonic_buffer_resource mr{nullptr, expect_next_buffer_size, std::pmr::new_delete_resource()};
+
+      for (int i = 0; i < 100; ++i) {
+        (void)mr.allocate(1);
+        mr.release();
+        ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeGe(expect_next_buffer_size));
+      }
+    }
+    {
+      // when init given a buffer. after release(), reset current buffer
----------------
philnik777 wrote:

I'm just asking for something like `// Check whether the offset into the initial buffer has been reset after release()`. Full sentences make it _way_ easier to understand what you're trying to do. A similar refactoring for the above would also be nice FWIW, but I won't insist, since I did at least understand it after reading it twice.

https://github.com/llvm/llvm-project/pull/116772


More information about the libcxx-commits mailing list