Zserio C++17 runtime library  0.5.0
Built for Zserio 2.17.0
zserio::BasicAny< ALLOC > Class Template Reference

#include <Any.h>

Inheritance diagram for zserio::BasicAny< ALLOC >:
Collaboration diagram for zserio::BasicAny< 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

 BasicAny ()
 
 BasicAny (const ALLOC &allocator)
 
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, BasicAny >::value &&!std::is_same< typename std::decay< T >::type, ALLOC >::value, int >::type = 0>
 BasicAny (T &&value, const ALLOC &allocator=ALLOC())
 
 ~BasicAny ()
 
 BasicAny (const BasicAny &other)
 
 BasicAny (const BasicAny &other, const ALLOC &allocator)
 
BasicAnyoperator= (const BasicAny &other)
 
 BasicAny (BasicAny &&other) noexcept
 
 BasicAny (BasicAny &&other, const ALLOC &allocator)
 
BasicAnyoperator= (BasicAny &&other)
 
template<typename T , typename std::enable_if<!std::is_same< typename std::decay< T >::type, BasicAny >::value, int >::type = 0>
BasicAnyoperator= (T &&value)
 
void reset ()
 
template<typename T >
void set (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::BasicAny< ALLOC >

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

Definition at line 228 of file Any.h.

Member Typedef Documentation

◆ allocator_type

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

Definition at line 236 of file Any.h.

Constructor & Destructor Documentation

◆ BasicAny() [1/7]

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

Empty constructor.

Definition at line 241 of file Any.h.

◆ BasicAny() [2/7]

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

Constructor from given allocator

Definition at line 248 of file Any.h.

◆ BasicAny() [3/7]

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

Constructor from any value.

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

Definition at line 263 of file Any.h.

◆ ~BasicAny()

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

Destructor.

Definition at line 273 of file Any.h.

◆ BasicAny() [4/7]

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

Copy constructor.

Parameters
otherAny holder to copy.

Definition at line 283 of file Any.h.

◆ BasicAny() [5/7]

template<typename ALLOC = std::allocator<uint8_t>>
zserio::BasicAny< ALLOC >::BasicAny ( const BasicAny< 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 296 of file Any.h.

◆ BasicAny() [6/7]

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

Move constructor.

Parameters
otherAny holder to move from.

Definition at line 330 of file Any.h.

◆ BasicAny() [7/7]

template<typename ALLOC = std::allocator<uint8_t>>
zserio::BasicAny< ALLOC >::BasicAny ( BasicAny< 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 342 of file Any.h.

Member Function Documentation

◆ get() [1/2]

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
T& zserio::BasicAny< 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 414 of file Any.h.

◆ get() [2/2]

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
const T& zserio::BasicAny< 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 428 of file Any.h.

◆ hasValue()

template<typename ALLOC = std::allocator<uint8_t>>
bool zserio::BasicAny< 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 450 of file Any.h.

◆ isType()

template<typename ALLOC = std::allocator<uint8_t>>
template<typename T >
bool zserio::BasicAny< 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 440 of file Any.h.

◆ operator=() [1/3]

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

Move assignment operator.

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

Definition at line 355 of file Any.h.

◆ operator=() [2/3]

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

Copy assignment operator.

Parameters
otherAny holder to copy.
Returns
Reference to this.

Definition at line 309 of file Any.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, BasicAny >::value, int >::type = 0>
BasicAny& zserio::BasicAny< ALLOC >::operator= ( T &&  value)
inline

Value assignment operator.

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

Definition at line 380 of file Any.h.

◆ reset()

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

Resets the holder.

Definition at line 390 of file Any.h.

◆ set()

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

Sets any value to the holder.

Parameters
valueAny value to set. Supports move semantic.

Definition at line 401 of file Any.h.


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