SPH
Public Member Functions | List of all members
AlignedStorage< Type > Class Template Reference

Simple block of memory on stack with size and alignment given by template type. More...

#include <AlignedStorage.h>

Public Member Functions

 AlignedStorage ()=default
 
template<typename... TArgs>
INLINE void emplace (TArgs &&... rest)
 
INLINE void destroy ()
 
constexpr INLINE operator Type & () noexcept
 Implicit conversion to stored type. More...
 
constexpr INLINE operator const Type & () const noexcept
 Implicit conversion to stored type, const version. More...
 
constexpr INLINE Type & get () noexcept
 Return the reference to the stored value. More...
 
constexpr INLINE const Type & get () const noexcept
 Returns the reference to the stored value, const version. More...
 

Detailed Description

template<typename Type>
class AlignedStorage< Type >

Simple block of memory on stack with size and alignment given by template type.

AlignedStorage can be used to construct an object on stack while sidestepping default construction. Objects can be therefore default-constructed even if the underlying type does not have default constructor. Stored object can be later constructed by calling emplace method. Note that when constructed, it has to be later destroyed by explicitly calling destroy method, this is not done automatically! This object does NO checks when the stored value is accessed, or whether it is constructed multiple times. This is left to the user.

Todo:
It's weird that GCC issues this warning as we are using may_alias attribute. Perhaps a bug?

Definition at line 56 of file AlignedStorage.h.

Constructor & Destructor Documentation

◆ AlignedStorage()

template<typename Type >
AlignedStorage< Type >::AlignedStorage ( )
default

Member Function Documentation

◆ destroy()

template<typename Type >
INLINE void AlignedStorage< Type >::destroy ( )
inline

Definition at line 70 of file AlignedStorage.h.

◆ emplace()

template<typename Type >
template<typename... TArgs>
INLINE void AlignedStorage< Type >::emplace ( TArgs &&...  rest)
inline

Definition at line 66 of file AlignedStorage.h.

◆ get() [1/2]

template<typename Type >
constexpr INLINE const Type& AlignedStorage< Type >::get ( ) const
inlineconstexprnoexcept

Returns the reference to the stored value, const version.

Definition at line 90 of file AlignedStorage.h.

◆ get() [2/2]

template<typename Type >
constexpr INLINE Type& AlignedStorage< Type >::get ( )
inlineconstexprnoexcept

Return the reference to the stored value.

Definition at line 85 of file AlignedStorage.h.

◆ operator const Type &()

template<typename Type >
constexpr INLINE AlignedStorage< Type >::operator const Type & ( ) const
inlineconstexprnoexcept

Implicit conversion to stored type, const version.

Definition at line 80 of file AlignedStorage.h.

◆ operator Type &()

template<typename Type >
constexpr INLINE AlignedStorage< Type >::operator Type & ( )
inlineconstexprnoexcept

Implicit conversion to stored type.

Definition at line 75 of file AlignedStorage.h.


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