stellarlib 0.1.0
Loading...
Searching...
No Matches
stellarlib::ext::arena Class Reference

Fixed-size, page-aligned memory arena. More...

#include <memory.hpp>

Inheritance diagram for stellarlib::ext::arena:

Public Types

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

Public Member Functions

 arena (size_type capacity) noexcept
 Parameterized constructor.
constexpr arena (const arena &) noexcept=delete
 Deleted copy constructor.
 arena (arena &&other) noexcept
 Move constructor.
constexpr auto operator= (const arena &) noexcept -> arena &=delete
 Deleted copy assignment operator.
auto operator= (arena &&other) noexcept -> arena &
 Move assignment operator.
 ~arena () noexcept
 Destructor.
auto capacity () const noexcept -> size_type
 Returns the remaining capacity of the arena in bytes.
template<typename T>
constexpr auto allocate () noexcept
 Returns uninitialized memory for type T.
auto operator== (const arena &other) const noexcept -> bool
 Comparison operator.
void deallocate () noexcept
 Resets the arena.

Detailed Description

Fixed-size, page-aligned memory arena.

Constructor & Destructor Documentation

◆ arena() [1/2]

stellarlib::ext::arena::arena ( size_type capacity)
explicitnodiscardnoexcept

Parameterized constructor.

Parameters
capacityRequested capacity of the arena in bytes

◆ arena() [2/2]

stellarlib::ext::arena::arena ( arena && other)
nodiscardnoexcept

Move constructor.

Parameters
otherOther instance

Member Function Documentation

◆ operator=()

auto stellarlib::ext::arena::operator= ( arena && other) -> arena &
noexcept

Move assignment operator.

Parameters
otherOther instance
Returns
Current instance

◆ capacity()

auto stellarlib::ext::arena::capacity ( ) const -> size_type
nodiscardnoexcept

Returns the remaining capacity of the arena in bytes.

Returns
Remaining capacity of the arena in bytes

◆ allocate()

template<typename T>
auto stellarlib::ext::arena::allocate ( )
inlinenodiscardconstexprnoexcept

Returns uninitialized memory for type T.

Template Parameters
TType to determine alignment and size
Returns
Uninitialized memory for type T, or nullptr if arena is exhausted

◆ operator==()

auto stellarlib::ext::arena::operator== ( const arena & other) const -> bool
nodiscardnoexcept

Comparison operator.

Parameters
otherOther instance
Returns
Result of the comparison

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