29 #ifndef BIT_MEMORY_ALLOCATORS_POLICY_ALLOCATOR_HPP 30 #define BIT_MEMORY_ALLOCATORS_POLICY_ALLOCATOR_HPP 32 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 34 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 36 #include "../utilities/ebo_storage.hpp" 37 #include "../utilities/allocator_info.hpp" 38 #include "../utilities/debugging.hpp" 39 #include "../utilities/errors.hpp" 40 #include "../utilities/macros.hpp" 42 #include "../concepts/Allocator.hpp" 43 #include "../concepts/ExtendedAllocator.hpp" 45 #include "../traits/allocator_traits.hpp" 76 template<
typename ExtendedAllocator,
77 typename MemoryTagger,
78 typename MemoryTracker,
79 typename BoundsChecker,
80 typename BasicLockable>
106 using lock_type = BasicLockable;
107 using tracker_type = MemoryTracker;
118 template<
typename...Args,
typename = std::enable_if_t<std::is_constructible<ExtendedAllocator,Args...>::value>>
150 policy_allocator&
operator=( policy_allocator&& other ) =
default;
158 policy_allocator&
operator=(
const policy_allocator& other ) =
default;
168 const tracker_type&
tracker()
const noexcept;
178 void*
try_allocate( std::size_t size, std::size_t align ) noexcept;
192 template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_can_truncate_deallocations<U>::value>>
207 template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_knows_ownership<U>::value>>
208 bool owns(
const void* p )
const noexcept;
217 template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_info<U>::value>>
235 template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_max_size<U>::value>>
236 std::size_t
max_size()
const noexcept;
244 template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_min_size<U>::value>>
245 std::size_t
min_size()
const noexcept;
251 #include "detail/policy_allocator.inl" std::size_t min_size() const noexcept
Gets the minimum size allocateable from this allocator.
allocator_info info() const noexcept
Retrieves info about this allocator.
const tracker_type & tracker() const noexcept
Accesses the tracker from the policy_allocator.
Type-trait to determine the default alignment of the given T.
void deallocate(void *p, std::size_t size)
Deallocates the pointer p with the size size.
void deallocate_all()
Deallocates all memory in this allocator.
Type-trait to determine the maximum alignment of the given T.
bool owns(const void *p) const noexcept
Checks if p is owned by the underlying allocator.
~policy_allocator()
Destructs the policy allocator, checking for any leaks.
This allocator manages policy-based memory allocation strategies using policy-based-design.
std::size_t max_size() const noexcept
Gets the maximum size allocateable from this allocator.
void * try_allocate(std::size_t size, std::size_t align) noexcept
Attempts to allocate size bytes aligned to a boundary of align using the underlying allocator...
This type is used to hold the generic information for a given allocator.
policy_allocator & operator=(policy_allocator &&other)=default
Move-assigns this policy_allocator from another allocator.
policy_allocator(Args &&...args)
Constructs an policy_allocator by forwarding all arguments to the underlying ExtendedAllocator.
A utility class used for leveraging empty-base optimization for a generic sequence of types...