mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-26 20:30:06 +01:00
Minor cleanup
This commit is contained in:
@@ -37,8 +37,7 @@ template <typename T> class mock_allocator {
|
||||
MOCK_METHOD(void, deallocate, (T*, size_t));
|
||||
};
|
||||
|
||||
template <typename Allocator, bool PropagateOnMove = false>
|
||||
class allocator_ref {
|
||||
template <typename Allocator, bool PropagateOnMove = true> class allocator_ref {
|
||||
private:
|
||||
Allocator* alloc_;
|
||||
|
||||
@@ -50,8 +49,7 @@ class allocator_ref {
|
||||
public:
|
||||
using value_type = typename Allocator::value_type;
|
||||
using propagate_on_container_move_assignment =
|
||||
typename std::conditional<PropagateOnMove, std::true_type,
|
||||
std::false_type>::type;
|
||||
fmt::bool_constant<PropagateOnMove>;
|
||||
|
||||
explicit allocator_ref(Allocator* alloc = nullptr) : alloc_(alloc) {}
|
||||
|
||||
@@ -70,23 +68,19 @@ class allocator_ref {
|
||||
}
|
||||
|
||||
public:
|
||||
Allocator* get() const { return alloc_; }
|
||||
auto get() const -> Allocator* { return alloc_; }
|
||||
|
||||
value_type* allocate(size_t n) {
|
||||
auto allocate(size_t n) -> value_type* {
|
||||
return std::allocator_traits<Allocator>::allocate(*alloc_, n);
|
||||
}
|
||||
void deallocate(value_type* p, size_t n) { alloc_->deallocate(p, n); }
|
||||
|
||||
FMT_CONSTEXPR20 friend bool operator==(const allocator_ref& a,
|
||||
const allocator_ref& b) noexcept {
|
||||
friend auto operator==(allocator_ref a, allocator_ref b) noexcept -> bool {
|
||||
if (a.alloc_ == b.alloc_) return true;
|
||||
if (a.alloc_ == nullptr || b.alloc_ == nullptr) return false;
|
||||
|
||||
return *a.alloc_ == *b.alloc_;
|
||||
return a.alloc_ && b.alloc_ && *a.alloc_ == *b.alloc_;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR20 friend bool operator!=(const allocator_ref& a,
|
||||
const allocator_ref& b) noexcept {
|
||||
friend auto operator!=(allocator_ref a, allocator_ref b) noexcept -> bool {
|
||||
return !(a == b);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user