STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Static Public Member Functions
stapl::runtime::packed_object_storage< T, Empty > Class Template Reference

Storage for object of type T used in communication. More...

Public Member Functions

 packed_object_storage (T const &t, void *const base, std::size_t &size) noexcept
 Constructs a new object by packing t in it. More...
 
 packed_object_storage (packed_object_storage const &)=delete
 
packed_object_storageoperator= (packed_object_storage const &)=delete
 
T & get (void *const base)
 Returns the stored object after unpacking it. More...
 
T & get (void *const base, std::size_t &size)
 Returns the stored object after unpacking it. More...
 

Static Public Member Functions

static std::size_t packed_size (T const &t) noexcept
 Returns the packed size of t.
 

Detailed Description

template<typename T, bool Empty = (std::is_empty<T>::value || std::is_same<T, std::nullptr_t>::value)>
class stapl::runtime::packed_object_storage< T, Empty >

Storage for object of type T used in communication.

Template Parameters
TObject type.

This class uses a properly aligned char array to store an object of type T. The static part of the object is copied in the array, while the dynamic part (e.g. any heap allocated space that a member of T points to) will be copied in the extra space during packing in the constructor.

An explicit call to get() is necessary to retrieve the stored object.

Warning
Calling the destructor after get() is necessary to avoid memory leaks.
There can be only a single call to the get(void*const) and get(void*const,std::size_t&) functions.
See also
typer_traits

Constructor & Destructor Documentation

◆ packed_object_storage()

template<typename T, bool Empty = (std::is_empty<T>::value || std::is_same<T, std::nullptr_t>::value)>
stapl::runtime::packed_object_storage< T, Empty >::packed_object_storage ( T const &  t,
void *const  base,
std::size_t &  size 
)
noexcept

Constructs a new object by packing t in it.

This constructor will copy the dynamic part of the object at base + size, which should be big enough to fit it.

Parameters
tObject to pack.
basePointer to buffer start where the dynamic part of t can be stored in.
sizeOffset from base where space is available.

Member Function Documentation

◆ get() [1/2]

template<typename T, bool Empty = (std::is_empty<T>::value || std::is_same<T, std::nullptr_t>::value)>
T& stapl::runtime::packed_object_storage< T, Empty >::get ( void *const  base)

Returns the stored object after unpacking it.

Parameters
baseBuffer where the dynamic part of the object is stored.

◆ get() [2/2]

template<typename T, bool Empty = (std::is_empty<T>::value || std::is_same<T, std::nullptr_t>::value)>
T& stapl::runtime::packed_object_storage< T, Empty >::get ( void *const  base,
std::size_t &  size 
)

Returns the stored object after unpacking it.

Parameters
baseBuffer where the dynamic part of the object is stored.
sizeVariable to store how many bytes were unpacked.

Member Data Documentation

◆ m_force_alignment

template<typename T, bool Empty = (std::is_empty<T>::value || std::is_same<T, std::nullptr_t>::value)>
aligned_storage_t<sizeof(value_type)> stapl::runtime::packed_object_storage< T, Empty >::m_force_alignment

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