siplasplas
A library for C++ reflection and introspection
cpp::typeerasure::Field< Storage, ObjectArgStorage > Class Template Reference

Stores a type erased member object pointer. More...

#include <siplasplas/typeerasure/field.hpp>

Public Member Functions

bool empty () const
 Checks if the field is empty Empty is defined as having no member object pointer assigned to the Field object. See SimpleAny::empty()
 
cpp::FunctionKind kind () const
 Returns a reference to the member object pointer stored by the Field object. More...
 
template<typename T , typename = std::enable_if_t< std::is_member_object_pointer<std::decay_t<T>>::value >>
 Field (T &&field)
 Initializes a Field with a given member object pointer.
 
template<typename Object >
decltype(auto) get (const Object &object) const
 Returns the value of the member object of a given object. More...
 
template<typename T , typename Object >
decltype(auto) getAs (const Object &object) const
 Returns the value of the member object of a given object. More...
 
template<typename Object >
decltype(auto) get (Object &object) const
 Returns the value of the member object of a given object. More...
 
template<typename T , typename Object >
decltype(auto) getAs (Object &object) const
 Returns the value of the member object of a given object. More...
 
template<typename Storage_ >
decltype(auto) get (const cpp::SimpleAny< Storage_ > &object) const
 Returns the value of the member object of a given type-erased object. More...
 
template<typename T , typename Storage_ >
decltype(auto) getAs (const cpp::SimpleAny< Storage_ > &object) const
 Returns the value of the member object of a given type erased object. More...
 
template<typename Storage_ >
decltype(auto) get (cpp::SimpleAny< Storage_ > &object) const
 Returns the value of the member object of a given type-erased object. More...
 
decltype(auto) get (cpp::ReferenceSimpleAny &object) const
 Returns the value of the member object of a given type-erased object reference. More...
 
decltype(auto) get (cpp::ConstReferenceSimpleAny &object) const
 Returns the value of the member object of a given type-erased object reference. More...
 
template<typename T , typename Storage_ >
decltype(auto) getAs (cpp::SimpleAny< Storage_ > &object) const
 Returns the value of the member object of a given type erased object. More...
 
template<typename T >
std::enable_if_t< std::is_member_object_pointer< std::decay_t< T > >::value, Field & > operator= (T &&field)
 Assigns a new member object pointer to the Field object.
 
template<typename T >
const T & get () const
 Returns a reference to the member object pointer stored by the Field object. More...
 
template<typename T >
T & get ()
 Returns a reference to the member object pointer stored by the Field object. More...
 

Detailed Description

template<typename Storage, typename ObjectArgStorage = Storage>
class cpp::typeerasure::Field< Storage, ObjectArgStorage >

Stores a type erased member object pointer.

Field class can store pointers to member objects of any class and type, suitable to be stored in an homogeneous context (Such as a vector). It also provides methods to access the type-erased pointer and access the member object of a given object

Template Parameters
StorageStorage for the member function pointer
ObjectArgStorageStorage for the object argument of a get() call

Member Function Documentation

template<typename Storage , typename ObjectArgStorage = Storage>
template<typename Object >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( const Object &  object) const
inline

Returns the value of the member object of a given object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename Object >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( Object &  object) const
inline

Returns the value of the member object of a given object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given object Returns a reference to the member object pointer stored by the Field object

The behavior is undefined if the Field object is empty

Template Parameters
TMember object pointer. The behavior is undefined if is not the type of the member object pointer stored by the Field object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename Storage_ >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( const cpp::SimpleAny< Storage_ > &  object) const
inline

Returns the value of the member object of a given type-erased object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename Storage_ >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( cpp::SimpleAny< Storage_ > &  object) const
inline

Returns the value of the member object of a given type-erased object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( cpp::ReferenceSimpleAny object) const
inline

Returns the value of the member object of a given type-erased object reference.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( cpp::ConstReferenceSimpleAny object) const
inline

Returns the value of the member object of a given type-erased object reference.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Returns
A type-erased reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T >
const T& cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( ) const
inline

Returns a reference to the member object pointer stored by the Field object.

The behavior is undefined if the Field object is empty

Template Parameters
TMember object pointer. The behavior is undefined if is not the type of the member object pointer stored by the Field object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T >
T& cpp::typeerasure::Field< Storage, ObjectArgStorage >::get ( )
inline

Returns a reference to the member object pointer stored by the Field object.

The behavior is undefined if the Field object is empty

Template Parameters
TMember object pointer. The behavior is undefined if is not the type of the member object pointer stored by the Field object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T , typename Object >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::getAs ( const Object &  object) const
inline

Returns the value of the member object of a given object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Template Parameters
TType of the member object. The behavior is undefined if this is not the type of the member object
Returns
A reference to the member object in the given object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T , typename Object >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::getAs ( Object &  object) const
inline

Returns the value of the member object of a given object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Template Parameters
TType of the member object. The behavior is undefined if this is not the type of the member object
Returns
A reference to the member object in the given object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T , typename Storage_ >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::getAs ( const cpp::SimpleAny< Storage_ > &  object) const
inline

Returns the value of the member object of a given type erased object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Template Parameters
TType of the member object. The behavior is undefined if this is not the type of the member object
Returns
A reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
template<typename T , typename Storage_ >
decltype(auto) cpp::typeerasure::Field< Storage, ObjectArgStorage >::getAs ( cpp::SimpleAny< Storage_ > &  object) const
inline

Returns the value of the member object of a given type erased object.

This function accesses to the member object referenced by the Field object on a given object. The behavior is undefined if the given object is not of the same class the stored member object pointer belongs to. Also, the behavior is undefined if the Field object is empty.

Template Parameters
TType of the member object. The behavior is undefined if this is not the type of the member object
Returns
A reference to the member object in the given type-erased object
template<typename Storage , typename ObjectArgStorage = Storage>
cpp::FunctionKind cpp::typeerasure::Field< Storage, ObjectArgStorage >::kind ( ) const
inline

Returns a reference to the member object pointer stored by the Field object.

The behavior is undefined if the Field object is empty

Template Parameters
TMember object pointer. The behavior is undefined if is not the type of the member object pointer stored by the Field object Returns the kind of the member object pointer

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