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

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

#include <siplasplas/typeerasure/simpleany.hpp>

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

Public Member Functions

bool empty () const
 Checks whether the any has an object hosted in or if is empty. More...
 
template<typename T >
 SimpleAny (T &value)
 
 SimpleAny (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...
 
template<typename T >
std::decay_t< T > & get ()
 Returns a 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::NonOwningStorage
 NonOwningStorage (void *object)
 Initializes the storage pointing it to the given object. More...
 
void rebind (void *object)
 Reassigns the storage to reference another object. More...
 
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< NonOwningStorage >

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

Member Function Documentation

bool cpp::SimpleAny< NonOwningStorage >::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< NonOwningStorage >::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 >
std::decay_t<T>& cpp::SimpleAny< NonOwningStorage >::get ( )
inline

Returns a 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< NonOwningStorage >::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< NonOwningStorage >::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: