[libcxx-commits] [libcxx] [libc++][test] Fix construction and comparison for testing allocators (PR #212702)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 30 07:56:41 PDT 2026
================
@@ -195,8 +195,14 @@ class test_allocator {
++stats_->destroy_count;
p->~T();
}
- TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { return x.data_ == y.data_; }
- TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { return !(x == y); }
+ template <class U>
+ TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator<U>& y) {
+ return x.data_ == static_cast<const test_allocator&>(y).data_;
----------------
ldionne wrote:
I'm probably missing something obvious, but I don't see how the current `static_cast<test_allocator const&>` is working. `test_allocator<T>` and `test_allocator<U>` are unrelated, so how does this static cast even work?
https://github.com/llvm/llvm-project/pull/212702
More information about the libcxx-commits
mailing list