[libcxx-commits] [libcxx] [libc++][test] Fix invalid low-level const conversion in limited_allocator (PR #118189)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 6 05:59:34 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(); }
----------------
ldionne wrote:
IMO we should instead do this:
```suggestion
TEST_CONSTEXPR const BuffT* getHandle() const { return handle_.get(); }
```
Let's just provide the `const` version, since the non-const version is not needed. This method is only used by `operator==` below.
The comment can also be removed if we only have the `const` version. WDYT?
https://github.com/llvm/llvm-project/pull/118189
More information about the libcxx-commits
mailing list