This allocator manages policy-based memory allocation strategies using policy-based-design.
More...
|
template<typename... Args, typename = std::enable_if_t<std::is_constructible<ExtendedAllocator,Args...>::value>> |
| policy_allocator (Args &&...args) |
| Constructs an policy_allocator by forwarding all arguments to the underlying ExtendedAllocator. More...
|
|
| policy_allocator (policy_allocator &&other)=default |
| Move-constructs this policy_allocator from another allocator. More...
|
|
| policy_allocator (const policy_allocator &other)=default |
| Copy-constructs this policy_allocator from another allocator. More...
|
|
| ~policy_allocator () |
| Destructs the policy allocator, checking for any leaks.
|
|
policy_allocator & | operator= (policy_allocator &&other)=default |
| Move-assigns this policy_allocator from another allocator. More...
|
|
policy_allocator & | operator= (const policy_allocator &other)=default |
| Copy-assigns this policy_allocator from another allocator. More...
|
|
const tracker_type & | tracker () const noexcept |
| Accesses the tracker from the policy_allocator. More...
|
|
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. More...
|
|
void | deallocate (void *p, std::size_t size) |
| Deallocates the pointer p with the size size . More...
|
|
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_can_truncate_deallocations<U>::value>> |
void | deallocate_all () |
| Deallocates all memory in this allocator. More...
|
|
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_knows_ownership<U>::value>> |
bool | owns (const void *p) const noexcept |
| Checks if p is owned by the underlying allocator. More...
|
|
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_info<U>::value>> |
allocator_info | info () const noexcept |
| Retrieves info about this allocator. More...
|
|
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_max_size<U>::value>> |
std::size_t | max_size () const noexcept |
| Gets the maximum size allocateable from this allocator. More...
|
|
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_min_size<U>::value>> |
std::size_t | min_size () const noexcept |
| Gets the minimum size allocateable from this allocator. More...
|
|
template<typename ExtendedAllocator, typename MemoryTagger, typename MemoryTracker, typename BoundsChecker, typename BasicLockable>
class bit::memory::policy_allocator< ExtendedAllocator, MemoryTagger, MemoryTracker, BoundsChecker, BasicLockable >
This allocator manages policy-based memory allocation strategies using policy-based-design.
It is comprised of debugger types that better help memory allocation strategies, while also supporting
- Note
- Since this is an policy allocator, it is not possible for all of the underlying policies to be stateless (since something must keep track of the used blocks); thus this class does not default itself to being stateless
- Satisfies
- Allocator
- Template Parameters
-
ExtendedAllocator | An allocator that satisfies the ExtendedAllocator concept |
MemoryTagger | A class used for tagging memory on allocations and on deallocations. |
MemoryTracker | A class used for tracking memory allocations. |
BoundsChecker | A class used for bounds checking; used to catch buffer-overflow issues |
BasicLockable | A lockable type for thread-synchronization |
Definition at line 81 of file policy_allocator.hpp.
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename... Args, typename = std::enable_if_t<std::is_constructible<ExtendedAllocator,Args...>::value>>
Constructs an policy_allocator by forwarding all arguments to the underlying ExtendedAllocator.
- Parameters
-
args | the arguments to forward to the ExtendedAllocator |
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_can_truncate_deallocations<U>::value>>
Deallocates all memory in this allocator.
- Note
- This function is only enabled if the underlying
ExtendedAllocator
supports it
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_info<U>::value>>
Retrieves info about this allocator.
- Note
- This function is only enabled if the underlying
ExtendedAllocator
supports it
- Returns
- the info about this allocator
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_max_size<U>::value>>
Gets the maximum size allocateable from this allocator.
- Note
- the max_size does not guarantee that the size is able to be allocated at the time the value is queried; it just means that it is the maximum size that the allocator is capable of allocating from an empty state.
- Parameters
-
alloc | the allocator to get the max size from |
- Returns
- the amount of bytes available for the largest possible allocation
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_has_min_size<U>::value>>
Gets the minimum size allocateable from this allocator.
- Note
- The default is 1, if this function is not defined
- Parameters
-
alloc | the allocator to get the min size from |
- Returns
- the minimum amount of bytes able to allocated
template<typename ExtendedAllocator , typename MemoryTagger , typename MemoryTracker , typename BoundsChecker , typename BasicLockable >
template<typename U = ExtendedAllocator, typename = std::enable_if_t<allocator_knows_ownership<U>::value>>
Checks if p
is owned by the underlying allocator.
- Note
- This function is only enabled if the underlying
ExtendedAllocator
supports it
- Parameters
-
- Returns
true
if p
is owned by this allocator