[libcxx-commits] [PATCH] D131079: [libcxx][test] fix allocator in allocator_propagation test
Casey Carter via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 3 09:46:52 PDT 2022
CaseyCarter created this revision.
CaseyCarter added a reviewer: libc++.
CaseyCarter added a project: libc++.
Herald added a project: All.
CaseyCarter requested review of this revision.
Herald added 1 blocking reviewer(s): libc++.
The converting constructor is ill-formed, and `==` is missing. (I didn't implement `!=` since the test is C++20-and-later only; I'll let the compiler do it for us.)
Drive-by: change 4-space indent on line 27 to 2-space indent to be consistent with the rest of the test.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131079
Files:
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
Index: libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
@@ -24,10 +24,10 @@
using value_type = T;
constexpr explicit soccc_allocator(int* soccc_count_, int self_coccc_count_ = 0)
- : soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
+ : soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
template <class U>
- constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.soccc_count) {}
+ constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.get_soccc()) {}
constexpr T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
constexpr void deallocate(T* p, std::size_t s) { std::allocator<T>().deallocate(p, s); }
@@ -37,12 +37,17 @@
return soccc_allocator(soccc_count, self_soccc_count + 1);
}
- constexpr auto get_soccc() { return soccc_count; }
- constexpr auto get_self_soccc() { return self_soccc_count; }
+ constexpr auto get_soccc() const { return soccc_count; }
+ constexpr auto get_self_soccc() const { return self_soccc_count; }
typedef std::true_type propagate_on_container_copy_assignment;
typedef std::true_type propagate_on_container_move_assignment;
typedef std::true_type propagate_on_container_swap;
+
+ template <class U>
+ constexpr bool operator==(const soccc_allocator<U>& that) const {
+ return soccc_count == that.get_soccc();
+ }
};
template <class CharT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131079.449691.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220803/46e0df02/attachment.bin>
More information about the libcxx-commits
mailing list