Namespace for utility functions on allocators
See bslma_allocatorutil
|
| template<class t_ALLOC > |
| static bsl::enable_if<!IsDerivedFromBslAllocator< t_ALLOC >::value, t_ALLOC >::type | adapt (const t_ALLOC &from) |
| |
| template<class t_TYPE > |
| static bslma::Allocator * | adapt (const bsl::allocator< t_TYPE > &from) |
| |
| template<class t_ALLOCATOR > |
| static AllocatorUtil_Traits< t_ALLOCATOR >::void_pointer | allocateBytes (const t_ALLOCATOR &allocator, std::size_t nbytes, std::size_t alignment=0) |
| |
| template<class t_TYPE , class t_ALLOCATOR > |
| static AllocatorUtil_Traits< t_ALLOCATOR, t_TYPE >::pointer | allocateObject (const t_ALLOCATOR &allocator, std::size_t n=1) |
| |
| template<class t_TYPE > |
| static t_TYPE & | assign (t_TYPE *lhs, const t_TYPE &rhs, bsl::true_type allowed) |
| |
| template<class t_TYPE > |
| static t_TYPE & | assign (t_TYPE *lhs, const t_TYPE &rhs, bsl::false_type allowed) |
| |
| template<class t_ALLOCATOR > |
| static void | deallocateBytes (const t_ALLOCATOR &allocator, typename AllocatorUtil_Traits< t_ALLOCATOR >::void_pointer p, std::size_t nbytes, std::size_t alignment=0) |
| |
| template<class t_ALLOCATOR , class t_POINTER > |
| static void | deallocateObject (const t_ALLOCATOR &allocator, t_POINTER p, std::size_t n=1) |
| |
| template<class t_ALLOCATOR , class t_POINTER > |
| static void | deleteObject (const t_ALLOCATOR &allocator, t_POINTER p) |
| |
| template<class t_TYPE , class t_ALLOCATOR > |
| static AllocatorUtil_Traits< t_ALLOCATOR, t_TYPE >::pointer | newObject (const t_ALLOCATOR &allocator) |
| |
| template<class t_TYPE , class t_ALLOCATOR , class t_ARG1 , class... t_ARGS> |
| static AllocatorUtil_Traits< t_ALLOCATOR, t_TYPE >::pointer | newObject (const t_ALLOCATOR &allocator, t_ARG1 &argument1, t_ARGS &&... arguments) |
| |
| template<class t_TYPE , class t_ALLOCATOR , class t_ARG1 , class... t_ARGS> |
| static AllocatorUtil_Traits< t_ALLOCATOR, t_TYPE >::pointer | newObject (const t_ALLOCATOR &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG1) argument1, t_ARGS &&... arguments) |
| |
| template<class t_TYPE > |
| static void | swap (t_TYPE *pa, t_TYPE *pb, bsl::false_type allowed) |
| |
| template<class t_TYPE > |
| static void | swap (t_TYPE *pa, t_TYPE *pb, bsl::true_type allowed) |
| |
template<class t_ALLOCATOR >
| AllocatorUtil_Traits< t_ALLOCATOR >::void_pointer bslma::AllocatorUtil::allocateBytes |
( |
const t_ALLOCATOR & |
allocator, |
|
|
std::size_t |
nbytes, |
|
|
std::size_t |
alignment = 0 |
|
) |
| |
|
inlinestatic |
Return a pointer to a block of raw memory allocated from the specified allocator having the specified nbytes size and optionally specified alignment. If alignment is not specified, the natural alignment for an object of size nbytes is used. If alignment is larger than the largest supported alignment for t_ALLOCATOR, either the block will be aligned to the maximum supported alignment or an exception will be thrown; the specific choice of behavior is determined by the allocator. For polymorphic allocators the behavior of extended alignment is determined by the memory resource, whereas for non-polymorphic allocators, the alignment is always truncated to the maximum non-extended alignment.
template<class t_TYPE , class t_ALLOCATOR , class t_ARG1 , class... t_ARGS>
Return an object of (template parameter) t_TYPE allocated from the specified allocator and constructed from the specified argument1 and other specified arguments. For scoped allocator types such as bsl::allocator and bsl::polymorphic_allocator, allocator may be passed to the t_TYPE constructor as an additional argument (i.e., if t_TYPE is AA).
- Note
- Note that, in C++03, perfect forwarding is limited such that any lvalue reference in the
arguments parameter pack is const-qualified when forwarded to the TARGET_TYPE constructor; only argument1 can be forwarded as an unqualified lvalue.