Skip to content

Commit

Permalink
Fix increasing_allocator to conform to standard
Browse files Browse the repository at this point in the history
  • Loading branch information
winner245 committed Nov 10, 2024
1 parent 7111d03 commit 4044fbe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct increasing_allocator {
min_elements += 1000;
return std::allocator<T>{}.allocate_at_least(n);
}
constexpr T* allocate(std::size_t n) { return allocate_at_least(n).ptr; }
constexpr T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
constexpr void deallocate(T* p, std::size_t n) noexcept { std::allocator<T>{}.deallocate(p, n); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct increasing_allocator {
min_elements += 1000;
return std::allocator<T>{}.allocate_at_least(n);
}
constexpr T* allocate(std::size_t n) { return allocate_at_least(n).ptr; }
constexpr T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
constexpr void deallocate(T* p, std::size_t n) noexcept { std::allocator<T>{}.deallocate(p, n); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ struct increasing_allocator {
min_bytes += 1000;
return {static_cast<T*>(::operator new(allocation_amount)), allocation_amount / sizeof(T)};
}
T* allocate(std::size_t n) { return allocate_at_least(n).ptr; }
void deallocate(T* p, std::size_t) noexcept { ::operator delete(static_cast<void*>(p)); }
T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
void deallocate(T* p, std::size_t) noexcept { std::allocator<T>{}.deallocate(p, n); }
};

template <typename T, typename U>
Expand Down

0 comments on commit 4044fbe

Please sign in to comment.