FancySafeBot 0.0.1
A safe robotics library
Loading...
Searching...
No Matches
fsb::WorkArray< T, Capacity > Class Template Referencefinal

Detailed Description

template<typename T, size_t Capacity>
class fsb::WorkArray< T, Capacity >

Fixed-capacity allocator for temporary work buffers.

Allocations are contiguous ranges within an internal std::array<T, Capacity>. This class performs no dynamic allocation.

#include <fsb_work.h>

Collaboration diagram for fsb::WorkArray< T, Capacity >:
Collaboration graph

Public Member Functions

size_t get_used () const noexcept
 
size_t get_remaining () const noexcept
 
T * data () noexcept
 
const T * data () const noexcept
 
void reset () noexcept
 Reset allocator state (frees all allocations).
 
size_t get_marker () const noexcept
 Get a marker representing the current top of stack.
 
WorkArrayStatus restore (size_t marker) noexcept
 Restore the allocator to a previous marker (LIFO bulk free).
 
WorkArrayStatus allocate (size_t len, WorkBlock< T > &out) noexcept
 Allocate a contiguous work block of len elements.
 
WorkArrayStatus deallocate (T *ptr, size_t len) noexcept
 Deallocate a work block previously returned by allocate().
 
WorkArrayStatus deallocate (const WorkBlock< T > &block) noexcept
 Deallocate a work block.
 

Static Public Member Functions

static constexpr size_t get_capacity () noexcept
 

Member Function Documentation

◆ allocate()

template<typename T , size_t Capacity>
WorkArrayStatus fsb::WorkArray< T, Capacity >::allocate ( size_t  len,
WorkBlock< T > &  out 
)
inlinenoexcept

Allocate a contiguous work block of len elements.

Parameters
[in]lenLength (in elements) to allocate.
[out]outFilled with pointer+length on success.
Returns
Status of the allocation.

◆ deallocate()

template<typename T , size_t Capacity>
WorkArrayStatus fsb::WorkArray< T, Capacity >::deallocate ( T *  ptr,
size_t  len 
)
inlinenoexcept

Deallocate a work block previously returned by allocate().

Parameters
[in]ptrPointer returned by allocate().
[in]lenLength originally allocated.
Returns
Status of the deallocation.

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