Skip to content

Commit d65e66a

Browse files
committed
[libcxx][test] fix allocator in allocator_propagation test
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. Differential Revision: https://reviews.llvm.org/D131079
1 parent 3f749a5 commit d65e66a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class soccc_allocator {
2424
using value_type = T;
2525

2626
constexpr explicit soccc_allocator(int* soccc_count_, int self_coccc_count_ = 0)
27-
: soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
27+
: soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
2828

2929
template <class U>
30-
constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.soccc_count) {}
30+
constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.get_soccc()) {}
3131

3232
constexpr T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
3333
constexpr void deallocate(T* p, std::size_t s) { std::allocator<T>().deallocate(p, s); }
@@ -37,12 +37,17 @@ class soccc_allocator {
3737
return soccc_allocator(soccc_count, self_soccc_count + 1);
3838
}
3939

40-
constexpr auto get_soccc() { return soccc_count; }
41-
constexpr auto get_self_soccc() { return self_soccc_count; }
40+
constexpr auto get_soccc() const { return soccc_count; }
41+
constexpr auto get_self_soccc() const { return self_soccc_count; }
4242

4343
typedef std::true_type propagate_on_container_copy_assignment;
4444
typedef std::true_type propagate_on_container_move_assignment;
4545
typedef std::true_type propagate_on_container_swap;
46+
47+
template <class U>
48+
constexpr bool operator==(const soccc_allocator<U>& that) const {
49+
return soccc_count == that.get_soccc();
50+
}
4651
};
4752

4853
template <class CharT>

0 commit comments

Comments
 (0)