30 #ifndef BIT_MEMORY_ALLOCATORS_FALLBACK_ALLOCATOR_HPP 31 #define BIT_MEMORY_ALLOCATORS_FALLBACK_ALLOCATOR_HPP 33 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 37 #include "detail/named_allocator.hpp" 39 #include "../utilities/ebo_storage.hpp" 40 #include "../utilities/macros.hpp" 41 #include "../utilities/owner.hpp" 43 #include "../concepts/Allocator.hpp" 45 #include "../traits/allocator_traits.hpp" 72 template<
typename...AllocatorStorages>
140 std::size_t align ) noexcept;
152 void deallocate( owner<void*> p, std::size_t size );
164 bool owns(
const void* p )
const noexcept;
175 std::size_t
max_size()
const noexcept;
181 std::size_t
min_size()
const noexcept;
188 template<std::
size_t Idx>
189 void* do_try_allocate( std::integral_constant<std::size_t,Idx>,
191 std::size_t align ) noexcept;
193 void* do_try_allocate( std::integral_constant<std::size_t,
sizeof...(AllocatorStorages)-1>,
195 std::size_t align ) noexcept;
199 template<std::
size_t Idx>
200 void do_deallocate( std::integral_constant<std::size_t,Idx>,
204 void do_deallocate( std::integral_constant<std::size_t,
sizeof...(AllocatorStorages)-1>,
213 template<std::size_t...Idxs>
214 bool do_owns( std::index_sequence<Idxs...>,
215 const void* p )
const noexcept;
222 template<std::size_t...Idxs>
223 std::size_t do_max_size( std::index_sequence<Idxs...> )
const noexcept;
225 template<std::size_t...Idxs>
226 std::size_t do_min_size( std::index_sequence<Idxs...> )
const noexcept;
234 template<
typename...Allocators>
235 using named_fallback_allocator = detail::named_allocator<
fallback_allocator<Allocators...>>;
245 template<
typename...AllocatorStorages>
247 make_fallback_allocator( AllocatorStorages...storages );
256 template<
typename...AllocatorStorages>
257 named_fallback_allocator<AllocatorStorages...>
258 make_named_fallback_allocator(
const char* name,
259 AllocatorStorages...storages );
264 #include "detail/fallback_allocator.inl" owner< void * > try_allocate(std::size_t size, std::size_t align) noexcept
Attempts to allocate memory, starting with the first allocator in sequence, and falling back to furth...
fallback_allocator(AllocatorStorages...storages) noexcept
Constructs each allocator in the fallback_allocator in-place, constructing each allocator from a sing...
fallback_allocator & operator=(fallback_allocator &&other)=default
Move-assigns the fallback_allocator from an existing one.
std::size_t max_size() const noexcept
Determines the maximum size of the allocations that this fallback_allocator supports.
bool owns(const void *p) const noexcept
Checks if any of the allocators in the fallback allocator owns the memory pointer to by p...
void deallocate(owner< void *> p, std::size_t size)
Deallocates the pointer p of size size from the underlying allocator.
This allocator acts as an aggregate that can fall back to other allocators on failure.
std::size_t min_size() const noexcept
Determines the minimum size of the allocations that this fallback_allocator supports.
A utility class used for leveraging empty-base optimization for a generic sequence of types...