Allocator#
Fully qualified name: carb::Allocator
Defined in carb/Memory.h
Structs#
- rebind
A struct that allows determining an allocator for class
Uthrough theothertype.
-
template<class T, class Align = std::integral_constant<size_t, 0>>
class Allocator# A class implementing the ‘Allocator’ C++ Named Requirement.
This class is usable for C++ classes that require an allocator, such as
std::vector.Note
This class requires dynamic or static linking to carb.dll/libcarb.so/libcarb.dylib in order to function.
- Template Parameters:
T – The type to allocate
Align – The requested alignment as a
std::integral_constant<size_t, value>. This must be a type in order to conform to the requirements ofstd::allocator_traitsthat template parameters be types. The constant value must be zero or a power of two. Zero indicates to useT’s required alignment.
Public Types
-
using void_pointer = void*#
void_pointer
-
using const_void_pointer = const void*#
const_void_pointer
Public Functions
-
constexpr Allocator() noexcept = default#
Constructor.
-
template<class U, class UAlign>
inline constexpr Allocator(
) noexcept# Copy constructor.
-
template<class U, class UAlign>
inline constexpr Allocator &operator=(
) noexcept# Copy-assign operator.
-
~Allocator() = default#
Destructor.
-
inline pointer allocate(size_type n = 1)#
Allocates suitable storage for an array object of type
T[n]and creates the array, but does not construct array elements.If alignment is suitable (that is, not less than the required alignment of
T) it is used, otherwise the required alignment ofTis used.- Throws:
std::bad_alloc – if exceptions are enabled (CARB_EXCEPTIONS_ENABLED) and the underlying carb::allocate() failed.
- Parameters:
n – The number of elements of
Tto allocate space for.- Returns:
A pointer to memory that can contain an array of type
T[n], but no array elements have been constructed.
-
inline pointer allocate(size_type n, const_void_pointer p)#
Same as allocate(size_type) but may use
p(nullptror a pointer obtained from allocate()) to aid locality.- Parameters:
n – The number of elements of
Tto allocate space for.p – May be
nullptror a pointer obtained from allocate(). If non-nullptr,pis returned.
- Returns:
A pointer to memory that can contain an array of type
T[n], but no array elements have been constructed.
-
inline void deallocate(pointer p, size_type n) noexcept#
Deallocates storage pointed to by
p, which must be a value returned by a previous call to allocate() that has not been invalidated by an intervening call todeallocate.- Parameters:
p – A value returned by a previous call to allocate() and not previously passed to
deallocate.n – Must be the same size value that was originally passed to allocate().
-
inline size_type max_size() const noexcept#
Returns the largest value that can be passed to allocate().
- Returns:
the largest value that can be passed to allocate().
-
template<class X, class ...Args>
inline void construct(
)# Constructs an object of type
Xin previously-allocated storage at the address pointed to byp, usingargsas the constructor arguments.- Parameters:
p – The pointer at which to construct.
args – The constructor arguments.
-
template<class U>
struct rebind# A struct that allows determining an allocator for class
Uthrough theothertype.