riccaticpp
Loading...
Searching...
No Matches
riccati::arena_allocator< T, ArenaType > Struct Template Reference

#include <memory.hpp>

Public Types

using value_type = T
 

Public Member Functions

RICCATI_NO_INLINE arena_allocator (ArenaType *alloc, bool owns_alloc=false)
 
RICCATI_NO_INLINE arena_allocator ()
 
RICCATI_NO_INLINE arena_allocator (const arena_allocator &rhs)
 
template<typename U , typename UArena >
RICCATI_NO_INLINE arena_allocator (const arena_allocator< U, UArena > &rhs)
 
 ~arena_allocator ()
 
template<typename T_ = T>
RICCATI_ALWAYS_INLINE T_ * allocate (std::size_t n)
 
RICCATI_ALWAYS_INLINE void recover_memory () noexcept
 
void deallocate (T *, std::size_t) noexcept
 
constexpr bool operator== (const arena_allocator &) const noexcept
 
constexpr bool operator!= (const arena_allocator &) const noexcept
 

Public Attributes

ArenaType * alloc_
 
bool owns_alloc_ {false}
 

Detailed Description

template<typename T, typename ArenaType>
struct riccati::arena_allocator< T, ArenaType >

std library compatible allocator that uses AD stack.

Template Parameters
Ttype of scalar
Warning
The type T needs to be either trivially destructible or the dynamic allocations needs to be managed by the arena_allocator. For example this works:
using my_matrix = std::vector<std::vector<double,
stan::math::arena_allocator<double>>,
stan::math::arena_allocator<std::vector<double,
stan::math::arena_allocator<double>>>>;

Definition at line 310 of file memory.hpp.

Member Typedef Documentation

◆ value_type

template<typename T , typename ArenaType >
using riccati::arena_allocator< T, ArenaType >::value_type = T

Definition at line 313 of file memory.hpp.

Constructor & Destructor Documentation

◆ arena_allocator() [1/4]

template<typename T , typename ArenaType >
RICCATI_NO_INLINE riccati::arena_allocator< T, ArenaType >::arena_allocator ( ArenaType * alloc,
bool owns_alloc = false )
inlineexplicit

Definition at line 314 of file memory.hpp.

◆ arena_allocator() [2/4]

template<typename T , typename ArenaType >
RICCATI_NO_INLINE riccati::arena_allocator< T, ArenaType >::arena_allocator ( )
inline

Definition at line 317 of file memory.hpp.

◆ arena_allocator() [3/4]

template<typename T , typename ArenaType >
RICCATI_NO_INLINE riccati::arena_allocator< T, ArenaType >::arena_allocator ( const arena_allocator< T, ArenaType > & rhs)
inline

Definition at line 320 of file memory.hpp.

◆ arena_allocator() [4/4]

template<typename T , typename ArenaType >
template<typename U , typename UArena >
RICCATI_NO_INLINE riccati::arena_allocator< T, ArenaType >::arena_allocator ( const arena_allocator< U, UArena > & rhs)
inline

Definition at line 323 of file memory.hpp.

◆ ~arena_allocator()

template<typename T , typename ArenaType >
riccati::arena_allocator< T, ArenaType >::~arena_allocator ( )
inline

Member Function Documentation

◆ allocate()

template<typename T , typename ArenaType >
template<typename T_ = T>
RICCATI_ALWAYS_INLINE T_ * riccati::arena_allocator< T, ArenaType >::allocate ( std::size_t n)
inline

Allocates space for n items of type T.

Parameters
nnumber of items to allocate space for
Returns
pointer to allocated space

Definition at line 339 of file memory.hpp.

References riccati::arena_allocator< T, ArenaType >::alloc_.

◆ deallocate()

template<typename T , typename ArenaType >
void riccati::arena_allocator< T, ArenaType >::deallocate ( T * ,
std::size_t  )
inlinenoexcept

No-op. Memory is deallocated by calling recover_memory().

Definition at line 353 of file memory.hpp.

◆ operator!=()

template<typename T , typename ArenaType >
bool riccati::arena_allocator< T, ArenaType >::operator!= ( const arena_allocator< T, ArenaType > & ) const
inlineconstexprnoexcept

Inequality comparison operator.

Returns
false

Definition at line 366 of file memory.hpp.

◆ operator==()

template<typename T , typename ArenaType >
bool riccati::arena_allocator< T, ArenaType >::operator== ( const arena_allocator< T, ArenaType > & ) const
inlineconstexprnoexcept

Equality comparison operator.

Returns
true

Definition at line 359 of file memory.hpp.

◆ recover_memory()

template<typename T , typename ArenaType >
RICCATI_ALWAYS_INLINE void riccati::arena_allocator< T, ArenaType >::recover_memory ( )
inlinenoexcept

Recovers memory

Definition at line 346 of file memory.hpp.

References riccati::arena_allocator< T, ArenaType >::alloc_.

Member Data Documentation

◆ alloc_

template<typename T , typename ArenaType >
ArenaType* riccati::arena_allocator< T, ArenaType >::alloc_

Definition at line 311 of file memory.hpp.

◆ owns_alloc_

template<typename T , typename ArenaType >
bool riccati::arena_allocator< T, ArenaType >::owns_alloc_ {false}

Definition at line 312 of file memory.hpp.


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