Zserio C++ runtime library  1.0.0
Built for Zserio 2.13.0
zserio::AnyHolder< ALLOC > Class Template Reference

#include <AnyHolder.h>

Inheritance diagram for zserio::AnyHolder< ALLOC >:
Collaboration diagram for zserio::AnyHolder< ALLOC >:

Public Types

using allocator_type = ALLOC
 
- Public Types inherited from zserio::AllocatorHolder< ALLOC >
using allocator_type = ALLOC
 

Public Member Functions

 AnyHolder ()
 
 AnyHolder (const ALLOC &allocator)
 
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, AnyHolder >::value &&!std::is_same< typename std::decay< T >::type, ALLOC >::value, int >::type = 0>
 AnyHolder (T &&value, const ALLOC &allocator=ALLOC())
 
template<typename T , typename std::enable_if< !std::is_same< typename std::decay< T >::type, AnyHolder >::value, int >::type = 0>
 AnyHolder (NoInitT, T &&value, const ALLOC &allocator=ALLOC())
 
 ~AnyHolder ()
 
 AnyHolder (const AnyHolder &other)
 
 AnyHolder (NoInitT, const AnyHolder &other)
 
 AnyHolder (const AnyHolder &other, const ALLOC &allocator)
 
 AnyHolder (NoInitT, const AnyHolder &other, const ALLOC &allocator)
 
AnyHolderoperator= (const AnyHolder &other)
 
AnyHolderassign (NoInitT, const AnyHolder &other)
 
 AnyHolder (AnyHolder &&other) noexcept
 
 AnyHolder (NoInitT, AnyHolder &&other) noexcept
 
 AnyHolder (AnyHolder &&other, const ALLOC &allocator)
 
 AnyHolder (NoInitT, AnyHolder &&other, const ALLOC &allocator)
 
AnyHolderoperator= (AnyHolder &&other)
 
AnyHolderassign (NoInitT, AnyHolder &&other)
 
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, AnyHolder >::value, int >::type = 0>
AnyHolderoperator= (T &&value)
 
void reset ()
 
template<typename T >
void set (T &&value)
 
template<typename T >
void set (NoInitT, T &&value)
 
template<typename T >
T & get ()
 
template<typename T >
const T & get () const
 
template<typename T >
bool isType () const
 
bool hasValue () const
 
- Public Member Functions inherited from zserio::AllocatorHolder< ALLOC >
 AllocatorHolder ()
 
 AllocatorHolder (const allocator_type &allocator)
 
 AllocatorHolder (allocator_type &&allocator)
 
allocator_type get_allocator () const
 
 ~AllocatorHolder ()=default
 
 AllocatorHolder (const AllocatorHolder &other)=default
 
AllocatorHolderoperator= (const AllocatorHolder &other)=default
 
 AllocatorHolder (AllocatorHolder &&other)=default
 
AllocatorHolderoperator= (AllocatorHolder &&other)=default
 

Additional Inherited Members

- Protected Member Functions inherited from zserio::AllocatorHolder< ALLOC >
void set_allocator (const allocator_type &allocator)
 
void set_allocator (allocator_type &&allocator)
 
allocator_typeget_allocator_ref ()
 
const allocator_typeget_allocator_ref () const
 

Detailed Description

template<typename ALLOC = std::allocator<uint8_t>>
class zserio::AnyHolder< ALLOC >

Type safe container for single values of any type which doesn't need RTTI.

Definition at line 319 of file AnyHolder.h.

Member Typedef Documentation

template<typename ALLOC = std::allocator<uint8_t>>
using zserio::AnyHolder< ALLOC >::allocator_type = ALLOC

Definition at line 327 of file AnyHolder.h.

Constructor & Destructor Documentation

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( )
inline

Empty constructor.

Definition at line 332 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( const ALLOC &  allocator)
inlineexplicit

Constructor from given allocator

Definition at line 339 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, AnyHolder >::value &&!std::is_same< typename std::decay< T >::type, ALLOC >::value, int >::type = 0>
zserio::AnyHolder< ALLOC >::AnyHolder ( T &&  value,
const ALLOC &  allocator = ALLOC() 
)
inlineexplicit

Constructor from any value.

Parameters
valueValue of any type to hold. Supports move semantic.

Definition at line 353 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T , typename std::enable_if< !std::is_same< typename std::decay< T >::type, AnyHolder >::value, int >::type = 0>
zserio::AnyHolder< ALLOC >::AnyHolder ( NoInitT  ,
T &&  value,
const ALLOC &  allocator = ALLOC() 
)
inlineexplicit

Constructor from any value which prevents initialization.

Parameters
valueValue of any type to hold. Supports move semantic.

Definition at line 367 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::~AnyHolder ( )
inline

Destructor.

Definition at line 377 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( const AnyHolder< ALLOC > &  other)
inline

Copy constructor.

Parameters
otherAny holder to copy.

Definition at line 387 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( NoInitT  ,
const AnyHolder< ALLOC > &  other 
)
inline

Copy constructor which prevents initialization.

Parameters
otherAny holder to copy.

Definition at line 399 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( const AnyHolder< ALLOC > &  other,
const ALLOC &  allocator 
)
inline

Allocator-extended copy constructor.

Parameters
otherAny holder to copy.
allocatorAllocator to be used for dynamic memory allocations.

Definition at line 412 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( NoInitT  ,
const AnyHolder< ALLOC > &  other,
const ALLOC &  allocator 
)
inline

Allocator-extended copy constructor which prevents initialization.

Parameters
otherAny holder to copy.
allocatorAllocator to be used for dynamic memory allocations.

Definition at line 423 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( AnyHolder< ALLOC > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherAny holder to move from.

Definition at line 476 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( NoInitT  ,
AnyHolder< ALLOC > &&  other 
)
inlinenoexcept

Move constructor which prevents initialization.

Parameters
otherAny holder to move from.

Definition at line 487 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( AnyHolder< ALLOC > &&  other,
const ALLOC &  allocator 
)
inline

Allocator-extended move constructor.

Parameters
otherAny holder to move from.
allocatorAllocator to be used for dynamic memory allocations.

Definition at line 499 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
zserio::AnyHolder< ALLOC >::AnyHolder ( NoInitT  ,
AnyHolder< ALLOC > &&  other,
const ALLOC &  allocator 
)
inline

Allocator-extended move constructor which prevents initialization.

Parameters
otherAny holder to move from.
allocatorAllocator to be used for dynamic memory allocations.

Definition at line 511 of file AnyHolder.h.

Member Function Documentation

template<typename ALLOC = std::allocator<uint8_t>>
AnyHolder& zserio::AnyHolder< ALLOC >::assign ( NoInitT  ,
const AnyHolder< ALLOC > &  other 
)
inline

Copy assignment operator which prevents initialization.

Parameters
otherAny holder to copy.
Returns
Reference to this.

Definition at line 457 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
AnyHolder& zserio::AnyHolder< ALLOC >::assign ( NoInitT  ,
AnyHolder< ALLOC > &&  other 
)
inline

Move assignment operator which prevents initialization.

Parameters
otherAny holder to move from.
Returns
Reference to this.

Definition at line 544 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
T& zserio::AnyHolder< ALLOC >::get ( )
inline

Gets value of the given type.

Returns
Reference to value of the requested type if the type match to the stored value.
Exceptions
CppRuntimeExceptionif the requested type doesn't match to the stored value.

Definition at line 611 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
const T& zserio::AnyHolder< ALLOC >::get ( ) const
inline

Gets value of the given type.

Returns
Value of the requested type if the type match to the stored value.
Exceptions
CppRuntimeExceptionif the requested type doesn't match to the stored value.

Definition at line 625 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
bool zserio::AnyHolder< ALLOC >::hasValue ( ) const
inline

Checks whether the holder has any value.

Returns
True if the holder has assigned any value, false otherwise.

Definition at line 647 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
bool zserio::AnyHolder< ALLOC >::isType ( ) const
inline

Check whether the holder holds the given type.

Returns
True if the stored value is of the given type, false otherwise.

Definition at line 637 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
AnyHolder& zserio::AnyHolder< ALLOC >::operator= ( const AnyHolder< ALLOC > &  other)
inline

Copy assignment operator.

Parameters
otherAny holder to copy.
Returns
Reference to this.

Definition at line 436 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
AnyHolder& zserio::AnyHolder< ALLOC >::operator= ( AnyHolder< ALLOC > &&  other)
inline

Move assignment operator.

Parameters
otherAny holder to move from.
Returns
Reference to this.

Definition at line 524 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, AnyHolder >::value, int >::type = 0>
AnyHolder& zserio::AnyHolder< ALLOC >::operator= ( T &&  value)
inline

Value assignment operator.

Parameters
valueAny value to assign. Supports move semantic.
Returns
Reference to this.

Definition at line 566 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
void zserio::AnyHolder< ALLOC >::reset ( )
inline

Resets the holder.

Definition at line 576 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
void zserio::AnyHolder< ALLOC >::set ( T &&  value)
inline

Sets any value to the holder.

Parameters
valueAny value to set. Supports move semantic.

Definition at line 587 of file AnyHolder.h.

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
void zserio::AnyHolder< ALLOC >::set ( NoInitT  ,
T &&  value 
)
inline

Sets any value to the holder and prevent initialization.

Parameters
valueAny value to set. Supports move semantic.

Definition at line 598 of file AnyHolder.h.


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