[libcxx-commits] [libcxx] [libc++][test] Fix invalid low-level const conversion in limited_allocator (PR #118189)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 6 06:11:12 PST 2024


================
@@ -467,7 +467,10 @@ class limited_allocator {
   TEST_CONSTEXPR_CXX20 pointer allocate(size_type n) { return handle_->template allocate<T>(n); }
   TEST_CONSTEXPR_CXX20 void deallocate(pointer p, size_type n) { handle_->template deallocate<T>(p, n); }
   TEST_CONSTEXPR size_type max_size() const { return N; }
-  TEST_CONSTEXPR BuffT* getHandle() const { return handle_.get(); }
+
+  // In C++11, constexpr non-static member functions are implicitly const, but this is no longer the case since C++14.
+  TEST_CONSTEXPR_CXX14 BuffT* getHandle() { return handle_.get(); }
+  TEST_CONSTEXPR const BuffT* getHandle() const { return handle_.get(); }
----------------
winner245 wrote:

Agree. We only need a `const` version.

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


More information about the libcxx-commits mailing list