is_allocator¶
Header¶
#include <tick/traits/is_allocator.h>
Description¶
An allocator encapsulates a memory allocation and deallocation strategy.
Requirements¶
Given:
T, a cv-unqualified object typeA, an Allocator type for typeTa, an object of typeAB, the corresponding allocator type for some cv-unqualified object typeU(as obtained by rebindingA)ptr, a value of typeallocator_traits<A>::pointer, obtained by callingallocator_traits<A>::allocate()cptr, a value of typeallocator_traits<A>::const_pointer, obtained by conversion fromptrvptr, a value of typeallocator_traits<A>::void_pointer, obtained by conversion fromptrcvptr, a value of typeallocator_traits<A>::const_void_pointer, obtained by conversion fromcptror fromvptrxptr, a dereferencable pointer to some cv-unqualified object typeXn, a value of typeallocator_traits<A>::size_type
| Expression | Requirements | Return type |
|---|---|---|
A::pointer (optional) |
Satisfies is_nullable_pointer and is_random_access_iterator |
|
A::const_pointer (optional) |
A::pointer is convertible to A::const_pointer. Satisfies is_nullable_pointer and is_random_access_iterator |
|
A::void_pointer (optional) |
A::pointer is convertible to A::void_pointer B::void_pointer and A::void_pointer are the same type. Satisfies is_nullable_pointer |
|
A::const_void_pointer (optional) |
A::pointer, A::const_pointer, and A::void_pointer are convertible to A::const_void_pointer `` B::const_void_pointer `` and A::const_void_pointer `` are the same type. Satisfies is_nullable_pointer |
|
A::value_type |
the type T |
|
*ptr |
T& |
|
*cptr |
*cptr and *ptr identify the same object |
const T& |
ptr->m |
same as (*ptr).m, if (*ptr).m is well-defined |
the type of T::m |
cptr->m |
same as (*cptr).m, if (*cptr).m is well-defined |
the type of T::m |
static_cast <A::pointer> (vptr) |
static_cast <A::pointer> (vptr) == ptr |
A::pointer |
static_cast <A::const_pointer>(cvptr) |
static_cast <A::const_pointer>(vptr) == cptr |
A::const_pointer |
a.allocate(n) |
allocates storage suitable for n objects of type T, but does not construct them. May throw exceptions. |
A::pointer |
a.deallocate(ptr, n) |
deallocates storage pointed to ptr, which must be a value returned by a previous call to allocate that has not been invalidated by an intervening call to deallocate. n must match the value previously passed to allocate. Does not throw exceptions. |
(not used) |
a.max_size () (optional) |
the largest value that can be passed to A::allocate() |
A::size_type |
a1 == a2 |
returns true only if the storage allocated by the allocator a1 can be deallocated through a2. Establishes reflexive, symmetric, and transitive relationship. Does not throw exceptions. |
bool |
a1 != a2 |
same as !(a1==a2) |
bool |
A a1(a) A a1 = a |
Copy-constructs a1 such that a1 == a. Does not throw exceptions. (Note: every allocator also satisfies is_copy_constructible |
|
A a(b) |
Constructs a such that B(a)==b and A(b)==a. Does not throw exceptions. (Note: this implies that all allocators related by rebind maintain each other’s resources, such as memory pools) |
|
A a1(std::move(a)) A a1 = std::move(a) |
Constructs a1 such that it equals the prior value of a. Does not throw exceptions. |
|
A a(std::move(b)) |
Constructs a such that it equals the prior value of A(b). Does not throw exceptions. |
Synopsis¶
TICK_TRAIT(is_allocator,
is_copy_constructible<_>,
is_equality_comparable<_>
)
{
template<class A>
auto require(const A& a)-> valid<
decltype(returns<is_nullable_pointer<_>, is_random_access_iterator<_>>(as_mutable(a).allocate(std::declval<std::size_t>()))),
decltype(returns<typename A::value_type&>(*(as_mutable(a).allocate(std::declval<std::size_t>()))))
>;
};




