30 #ifndef BIT_MEMORY_BLOCK_ALLOCATORS_MALLOC_BLOCK_ALLOCATOR_HPP 31 #define BIT_MEMORY_BLOCK_ALLOCATORS_MALLOC_BLOCK_ALLOCATOR_HPP 33 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 37 #include "detail/enum_types.hpp" 38 #include "detail/cached_block_allocator.hpp" 39 #include "detail/named_block_allocator.hpp" 41 #include "../utilities/ebo_storage.hpp" 42 #include "../utilities/dynamic_size_type.hpp" 43 #include "../utilities/allocator_info.hpp" 44 #include "../utilities/macros.hpp" 45 #include "../utilities/memory_block.hpp" 46 #include "../utilities/owner.hpp" 48 #include "../policies/growth_multipliers/no_growth.hpp" 52 #include <type_traits> 67 template<std::size_t DefaultBlockSize,
68 typename GrowthMultiplier=no_growth_multiplier>
81 using default_block_alignment = std::integral_constant<std::size_t,alignof(std::max_align_t)>;
100 template<std::size_t USize=DefaultBlockSize,
101 typename=std::enable_if_t<USize!=dynamic_size>>
111 template<std::size_t USize=DefaultBlockSize,
112 typename=std::enable_if_t<USize==dynamic_size>>
114 GrowthMultiplier growth = GrowthMultiplier{} );
132 malloc_block_allocator&
operator=( malloc_block_allocator&& other ) =
default;
138 malloc_block_allocator&
operator=(
const malloc_block_allocator& other ) =
default;
178 template<std::
size_t DefaultBlockSize,
typename GrowthMultiplier=no_growth_multiplier>
179 using cached_malloc_block_allocator
180 = detail::cached_block_allocator<malloc_block_allocator<DefaultBlockSize,GrowthMultiplier>>;
184 template<std::
size_t DefaultBlockSize,
typename GrowthMultiplier=no_growth_multiplier>
185 using named_malloc_block_allocator
186 = detail::named_block_allocator<malloc_block_allocator<DefaultBlockSize,GrowthMultiplier>>;
190 template<std::
size_t DefaultBlockSize,
typename GrowthMultiplier=no_growth_multiplier>
191 using named_cached_malloc_block_allocator
192 = detail::named_block_allocator<cached_malloc_block_allocator<DefaultBlockSize,GrowthMultiplier>>;
197 #include "detail/malloc_block_allocator.inl" This type is used as a compile-time constant for storing size values.
owner< memory_block > allocate_block() noexcept
Allocates a malloc'ed memory_block.
A block allocator that wraps around raw calls to std::malloc and std::free.
std::size_t next_block_size() const noexcept
Queries the next block size expected from this allocator.
allocator_info info() const noexcept
Gets the info about this allocator.
malloc_block_allocator & operator=(malloc_block_allocator &&other)=default
Move-assigns a malloc_block_allocator from another allocator.
void deallocate_block(owner< memory_block > block) noexcept
Deallocates a malloc'ed memory_block.
This type is used to hold the generic information for a given allocator.
malloc_block_allocator() noexcept=default
Default-constructs this malloc_block_allocator.
A utility class used for leveraging empty-base optimization for a generic sequence of types...