Zserio C++ runtime library  1.2.0
Built for Zserio 2.16.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< std::allocator< uint8_t > >
using allocator_type = std::allocator< uint8_t >
 

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< std::allocator< uint8_t > >
 AllocatorHolder ()
 
 AllocatorHolder (const allocator_type &allocator)
 
 AllocatorHolder (allocator_type &&allocator)
 
allocator_type get_allocator () const
 
 AllocatorHolder (const AllocatorHolder &other)=default
 
 AllocatorHolder (AllocatorHolder &&other)=default
 
 ~AllocatorHolder ()=default
 
AllocatorHolderoperator= (const AllocatorHolder &other)=default
 
AllocatorHolderoperator= (AllocatorHolder &&other)=default
 

Additional Inherited Members

- Protected Member Functions inherited from zserio::AllocatorHolder< std::allocator< uint8_t > >
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 317 of file AnyHolder.h.

Member Typedef Documentation

◆ allocator_type

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

Definition at line 325 of file AnyHolder.h.

Constructor & Destructor Documentation

◆ AnyHolder() [1/12]

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

Empty constructor.

Definition at line 330 of file AnyHolder.h.

◆ AnyHolder() [2/12]

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

Constructor from given allocator

Definition at line 337 of file AnyHolder.h.

◆ AnyHolder() [3/12]

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 352 of file AnyHolder.h.

◆ AnyHolder() [4/12]

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.

◆ ~AnyHolder()

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

Destructor.

Definition at line 377 of file AnyHolder.h.

◆ AnyHolder() [5/12]

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.

◆ AnyHolder() [6/12]

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.

◆ AnyHolder() [7/12]

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.

◆ AnyHolder() [8/12]

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 424 of file AnyHolder.h.

◆ AnyHolder() [9/12]

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 481 of file AnyHolder.h.

◆ AnyHolder() [10/12]

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 492 of file AnyHolder.h.

◆ AnyHolder() [11/12]

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 504 of file AnyHolder.h.

◆ AnyHolder() [12/12]

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 516 of file AnyHolder.h.

Member Function Documentation

◆ assign() [1/2]

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 551 of file AnyHolder.h.

◆ assign() [2/2]

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 460 of file AnyHolder.h.

◆ get() [1/2]

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 621 of file AnyHolder.h.

◆ get() [2/2]

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 635 of file AnyHolder.h.

◆ hasValue()

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 657 of file AnyHolder.h.

◆ isType()

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 647 of file AnyHolder.h.

◆ operator=() [1/3]

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 529 of file AnyHolder.h.

◆ operator=() [2/3]

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 437 of file AnyHolder.h.

◆ operator=() [3/3]

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 576 of file AnyHolder.h.

◆ reset()

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

Resets the holder.

Definition at line 586 of file AnyHolder.h.

◆ set() [1/2]

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 608 of file AnyHolder.h.

◆ set() [2/2]

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 597 of file AnyHolder.h.


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