Skip to content

Commit

Permalink
[libcxx][test] fix allocator in allocator_propagation test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CaseyCarter committed Jan 4, 2023
1 parent 3f749a5 commit d65e66a
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -24,10 +24,10 @@ class soccc_allocator {
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); }
Expand All @@ -37,12 +37,17 @@ class soccc_allocator {
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>
Expand Down

0 comments on commit d65e66a

Please sign in to comment.