stellarlib 0.1.0
Loading...
Searching...
No Matches
stellarlib::ext::vector_allocator< T, SizeType > Class Template Reference

Linear memory allocator optimized for vectors. More...

#include <memory.hpp>

Inheritance diagram for stellarlib::ext::vector_allocator< T, SizeType >:

Public Types

using value_type = std::allocator<T>::value_type
 Value type of the allocator.
using size_type = SizeType
 Size type of the allocator.
using difference_type = std::allocator<value_type>::difference_type
 Difference type of the allocator.
using propagate_on_container_move_assignment = std::allocator<value_type>::propagate_on_container_move_assignment
 Whether the allocator can be propagated on container move assignment.

Public Member Functions

constexpr vector_allocator () noexcept=default
 Default constructor.
constexpr vector_allocator (const vector_allocator &other) noexcept=default
 Copy constructor.
constexpr vector_allocator (vector_allocator &&other) noexcept=default
 Move constructor.
constexpr auto operator= (const vector_allocator &other) noexcept -> vector_allocator &=default
 Copy assignment operator.
constexpr auto operator= (vector_allocator &&other) noexcept -> vector_allocator &=default
 Move assignment operator.
constexpr ~vector_allocator () noexcept=default
 Destructor.
constexpr void allocate (value_type *&begin, const size_type capacity) const noexcept
 Allocates uninitialized memory for N instances of type T.
constexpr void reallocate (value_type *&begin, const size_type capacity) const noexcept
 Reallocates uninitialized memory for N instances of type T via bit-wise relocation.
constexpr void reallocate (value_type *&begin, const size_type size, size_type &capacity) const noexcept
 Reallocates uninitialized memory for at least N instances of type T via element-wise move.
constexpr auto operator== (const vector_allocator &other) const noexcept -> bool=default
 Comparison operator.
constexpr void deallocate (value_type *begin) const noexcept
 Deallocates uninitialized memory.

Detailed Description

template<typename T, typename SizeType = std::size_t>
class stellarlib::ext::vector_allocator< T, SizeType >

Linear memory allocator optimized for vectors.

Template Parameters
TValue type of the allocator
SizeTypeSize type of the allocator

Constructor & Destructor Documentation

◆ vector_allocator() [1/2]

template<typename T, typename SizeType = std::size_t>
stellarlib::ext::vector_allocator< T, SizeType >::vector_allocator ( const vector_allocator< T, SizeType > & other)
nodiscardconstexprdefaultnoexcept

Copy constructor.

Parameters
otherOther instance

◆ vector_allocator() [2/2]

template<typename T, typename SizeType = std::size_t>
stellarlib::ext::vector_allocator< T, SizeType >::vector_allocator ( vector_allocator< T, SizeType > && other)
nodiscardconstexprdefaultnoexcept

Move constructor.

Parameters
otherOther instance

Member Function Documentation

◆ operator=() [1/2]

template<typename T, typename SizeType = std::size_t>
auto stellarlib::ext::vector_allocator< T, SizeType >::operator= ( const vector_allocator< T, SizeType > & other) -> vector_allocator &=default
constexprdefaultnoexcept

Copy assignment operator.

Parameters
otherOther instance
Returns
Current instance

◆ operator=() [2/2]

template<typename T, typename SizeType = std::size_t>
auto stellarlib::ext::vector_allocator< T, SizeType >::operator= ( vector_allocator< T, SizeType > && other) -> vector_allocator &=default
constexprdefaultnoexcept

Move assignment operator.

Parameters
otherOther instance
Returns
Current instance

◆ allocate()

template<typename T, typename SizeType = std::size_t>
void stellarlib::ext::vector_allocator< T, SizeType >::allocate ( value_type *& begin,
const size_type capacity ) const
inlineconstexprnoexcept

Allocates uninitialized memory for N instances of type T.

Parameters
beginUpdated to point to the allocated memory
capacityNumber of instances to allocate

◆ reallocate() [1/2]

template<typename T, typename SizeType = std::size_t>
void stellarlib::ext::vector_allocator< T, SizeType >::reallocate ( value_type *& begin,
const size_type capacity ) const
inlineconstexprnoexcept

Reallocates uninitialized memory for N instances of type T via bit-wise relocation.

Parameters
beginPointer for existing memory; Updated to point to the reallocated memory
capacityNumber of instances to allocate

◆ reallocate() [2/2]

template<typename T, typename SizeType = std::size_t>
void stellarlib::ext::vector_allocator< T, SizeType >::reallocate ( value_type *& begin,
const size_type size,
size_type & capacity ) const
inlineconstexprnoexcept

Reallocates uninitialized memory for at least N instances of type T via element-wise move.

Parameters
beginPointer for existing memory; Updated to point to the reallocated memory
sizeNumber of initialized instances in existing memory
capacityRequested capacity; Updated to the actual allocated capacity

◆ operator==()

template<typename T, typename SizeType = std::size_t>
auto stellarlib::ext::vector_allocator< T, SizeType >::operator== ( const vector_allocator< T, SizeType > & other) const -> bool=default
nodiscardconstexprdefaultnoexcept

Comparison operator.

Parameters
otherOther instance
Returns
Result of the comparison

◆ deallocate()

template<typename T, typename SizeType = std::size_t>
void stellarlib::ext::vector_allocator< T, SizeType >::deallocate ( value_type * begin) const
inlineconstexprnoexcept

Deallocates uninitialized memory.

Parameters
beginPointer for existing memory

The documentation for this class was generated from the following file: