carb::Allocator
Defined in carb/Memory.h
Structs
- carb::Allocator::rebind: A struct that allows determining an allocator for class - Uthrough the- othertype.
- 
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 of- std::allocator_traitsthat template parameters be types. The constant value must be zero or a power of two. Zero indicates to use- T’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(const Allocator<U, UAlign> &other) noexcept
- Copy constructor. 
 - 
template<class U, class UAlign>
 inline constexpr Allocator &operator=(const Allocator<U, UAlign> &other) 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 of- Tis 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 to- deallocate.- 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(X *const p, Args&&... args)
- Constructs an object of type - Xin previously-allocated storage at the address pointed to by- p, using- argsas 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 the- othertype.