siplasplas
A library for C++ reflection and introspection
cpp::SimpleAny< ConstNonOwningStorage > Class Template Reference

cpp::SimpleAny specialization for non-owning const references to existing objects. See cpp::ConstNonOwningStorage More...

#include <siplasplas/typeerasure/simpleany.hpp>

Inheritance diagram for cpp::SimpleAny< ConstNonOwningStorage >:
cpp::ConstNonOwningStorage

Public Member Functions

bool empty () const
 Checks whether the any has an object hosted in or if is empty. More...
 
template<typename T >
 SimpleAny (const T &value)
 
 SimpleAny (const void *object, const cpp::typeerasure::TypeInfo &typeInfo)
 
template<typename T >
bool hasType () const
 Checks if the any has a value of type T. More...
 
template<typename T >
const std::decay_t< T > & get () const
 Returns a readonly reference to the hosted object. More...
 
cpp::typeerasure::TypeInfo typeInfo () const
 Returns the type information of the hosted type.
 
template<typename T >
SimpleAnyoperator= (const T &value)
 Assigns a value of type T. More...
 
- Public Member Functions inherited from cpp::ConstNonOwningStorage
 ConstNonOwningStorage (const void *object)
 Initializes the storage pointing it to the given object. More...
 
void rebind (const void *object)
 Reassigns the storage to reference another object. More...
 
const void * storage (cpp::typeerasure::TypeInfo typeInfo) const
 Returns a pointer to the storage memory space. More...
 

Static Public Member Functions

template<typename T >
static SimpleAny create (const T &value)
 Creates a const reference SimpleAny referencing the given object of type T.
 

Detailed Description

template<>
class cpp::SimpleAny< ConstNonOwningStorage >

cpp::SimpleAny specialization for non-owning const references to existing objects. See cpp::ConstNonOwningStorage

Member Function Documentation

bool cpp::SimpleAny< ConstNonOwningStorage >::empty ( ) const
inline

Checks whether the any has an object hosted in or if is empty.

Returns
True if the any is empty (There's no hosted object), false instead
template<typename T >
const std::decay_t<T>& cpp::SimpleAny< ConstNonOwningStorage >::get ( ) const
inline

Returns a readonly reference to the hosted object.

Template Parameters
TType of the returned object. If T is different from the hosted object type, the behavior is undefined (See hasType()).
template<typename T >
bool cpp::SimpleAny< ConstNonOwningStorage >::hasType ( ) const
inline

Checks if the any has a value of type T.

Returns
True if the hosted type is exactly T, false otherwise
template<typename T >
SimpleAny& cpp::SimpleAny< ConstNonOwningStorage >::operator= ( const T &  value)
inline

Assigns a value of type T.

If the current hosted type is T, performs a copy assignment of value into the hosted object. Else, the hosted reference is rebinded to point to the new value.

Parameters
valueValue to be assigned to the any
Returns
A reference to *this

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