Skip to content

Commit

Permalink
restored using allocator traits for the special case
Browse files Browse the repository at this point in the history
  • Loading branch information
dietmarkuehl committed Jan 23, 2025
1 parent 9653420 commit d9a2e56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/beman/lazy/detail/allocator_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ struct allocator_support {
template <typename... A>
static void* operator new(std::size_t size, A&&... a) {
if constexpr (::std::same_as<Allocator, ::std::allocator<::std::byte>>) {
return ::operator new(size);
Allocator alloc{};
return allocator_traits::allocate(alloc, size);

} else {
Allocator alloc{::beman::lazy::detail::find_allocator<Allocator>(a...)};
Expand All @@ -63,7 +64,8 @@ struct allocator_support {
}
static void operator delete(void* ptr, std::size_t size) {
if constexpr (::std::same_as<Allocator, ::std::allocator<::std::byte>>) {
::operator delete(ptr, size);
Allocator alloc{};
allocator_traits::deallocate(alloc, static_cast<std::byte*>(ptr), size);
} else {
Allocator* aptr{allocator_support::get_allocator(ptr, size)};
Allocator alloc{*aptr};
Expand Down

0 comments on commit d9a2e56

Please sign in to comment.