siplasplas
A library for C++ reflection and introspection
cpp::FixedSizeStorage< Size, Alignment > Class Template Reference

Implements fixed-size storage. More...

#include <siplasplas/typeerasure/anystorage/fixedsize.hpp>

Protected Member Functions

const char * begin () const
 Returns a pointer to the beginning of the storage.
 
char * begin ()
 Returns a pointer to the beginning of the storage.
 
const char * end () const
 Returns a pointer to the end of the storage.
 
char * end ()
 Returns a pointer to the end of the storage.
 
constexpr std::size_t size () const
 Returns the size in bytes of the storage.
 
const void * storage (cpp::typeerasure::TypeInfo typeInfo) const
 Returns a pointer to the storage memory space. More...
 
void * storage (cpp::typeerasure::TypeInfo typeInfo)
 Returns a pointer to the storage memory space. More...
 
template<typename T >
bool objectFitsInStorage () const
 Checks if an object can be hosted in the storage space. More...
 

Detailed Description

template<std::size_t Size, std::size_t Alignment = alignof(std::uint8_t)>
class cpp::FixedSizeStorage< Size, Alignment >

Implements fixed-size storage.

Template Parameters
SizeMax capacity of the storage
AlignmentStorage alignment. Alignof(std::uint8_t) by default

Member Function Documentation

template<std::size_t Size, std::size_t Alignment = alignof(std::uint8_t)>
template<typename T >
bool cpp::FixedSizeStorage< Size, Alignment >::objectFitsInStorage ( ) const
inlineprotected

Checks if an object can be hosted in the storage space.

Returns
True if properly-aligned values of type T fit in the storage, false otherwise
template<std::size_t Size, std::size_t Alignment = alignof(std::uint8_t)>
const void* cpp::FixedSizeStorage< Size, Alignment >::storage ( cpp::typeerasure::TypeInfo  typeInfo) const
inlineprotected

Returns a pointer to the storage memory space.

Parameters
typeInfoType information with the required alignment and storage size
Returns
An aligned pointer to the storage. The behavior is undefined if the storage has no space to host an object with the required alignment (See objectFitsInStorage()).
template<std::size_t Size, std::size_t Alignment = alignof(std::uint8_t)>
void* cpp::FixedSizeStorage< Size, Alignment >::storage ( cpp::typeerasure::TypeInfo  typeInfo)
inlineprotected

Returns a pointer to the storage memory space.

Parameters
typeInfoType information with the required alignment and storage size
Returns
An aligned pointer to the storage. The behavior is undefined if the storage has no space to host an object with the required alignment (See objectFitsInStorage()).

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