matador::any Class Reference

Simple any class. More...

#include <any.hpp>

Public Member Functions

 any ()=default
 Default constructor.
 
 any (any &&s) noexcept
 Move copy constructor.
 
 any (any const &s)
 Copy constructor.
 
template<typename T , typename U = decay<T>, typename = none<U>>
 any (T &&x)
 Create any from concrete object.
 
anyoperator= (any s)
 Assignment operator.
 
std::type_index type_index () const
 Get the type index of an any object.
 
void clear ()
 Clear any object.
 
bool empty () const
 Returns true if no object is assigned to any.
 
template<typename T >
bool is () const
 Checks type of any with given type.
 
template<typename T >
T && _ () &&
 Returns the moved any object as static cast.
 
template<typename T >
T & _ () &
 Returns reference to any object as static cast.
 
template<typename T >
T const & _ () const &
 Returns const reference to any object as static cast.
 
template<typename T >
T && cast () &&
 Returns the moved any object as dynamic cast.
 
template<typename T >
T & cast () &
 Returns reference to any object as dynamic cast.
 
template<typename T >
T const & cast () const &
 Returns const reference to any object as dynamic cast.
 
template<typename T >
 operator T&& () &&
 Returns the moved any object as static cast.
 
template<typename T >
 operator T& () &
 Returns reference to any object as static cast.
 
template<typename T >
 operator T const & () const &
 Returns const reference to any object as static cast.
 

Friends

void swap (any &s, any &r)
 Allow swapping of any objects.
 

Detailed Description

Simple any class.

Simple any class taken from here. This class is a template-less holder for any type of object.

Constructor & Destructor Documentation

◆ any() [1/4]

matador::any::any ( )
default

Default constructor.

Create an empty anonymous any

◆ any() [2/4]

matador::any::any ( any &&  s)
inlinenoexcept

Move copy constructor.

Parameters
sany object to be moved

◆ any() [3/4]

matador::any::any ( any const &  s)
inline

Copy constructor.

Parameters
sany object to be copied

◆ any() [4/4]

template<typename T , typename U = decay<T>, typename = none<U>>
matador::any::any ( T &&  x)
inline

Create any from concrete object.

Template Parameters
TType of object
UDecay type of object
Parameters
xConcrete object

Member Function Documentation

◆ _() [1/3]

template<typename T >
T & matador::any::_ ( ) &
inline

Returns reference to any object as static cast.

Template Parameters
TType of any
Returns
Reference to any object

◆ _() [2/3]

template<typename T >
T && matador::any::_ ( ) &&
inline

Returns the moved any object as static cast.

Template Parameters
TType of any
Returns
The moved any object

◆ _() [3/3]

template<typename T >
T const & matador::any::_ ( ) const &
inline

Returns const reference to any object as static cast.

Template Parameters
TType of any
Returns
Const reference to any object

◆ cast() [1/3]

template<typename T >
T & matador::any::cast ( ) &
inline

Returns reference to any object as dynamic cast.

Template Parameters
TType of any
Returns
Reference to any object

◆ cast() [2/3]

template<typename T >
T && matador::any::cast ( ) &&
inline

Returns the moved any object as dynamic cast.

Template Parameters
TType of any
Returns
The moved any object

◆ cast() [3/3]

template<typename T >
T const & matador::any::cast ( ) const &
inline

Returns const reference to any object as dynamic cast.

Template Parameters
TType of any
Returns
Const reference to any object

◆ clear()

void matador::any::clear ( )
inline

Clear any object.

Deletes the internal object

◆ empty()

bool matador::any::empty ( ) const
inline

Returns true if no object is assigned to any.

Returns
True if no object is assigned to any

◆ is()

template<typename T >
bool matador::any::is ( ) const
inline

Checks type of any with given type.

Template Parameters
TType to check with
Returns
True if types are the same

◆ operator T const &()

template<typename T >
matador::any::operator T const & ( ) const &
inline

Returns const reference to any object as static cast.

Template Parameters
TType of any
Returns
Const reference to any object

◆ operator T&()

template<typename T >
matador::any::operator T& ( ) &
inline

Returns reference to any object as static cast.

Template Parameters
TType of any
Returns
Reference to any object

◆ operator T&&()

template<typename T >
matador::any::operator T&& ( ) &&
inline

Returns the moved any object as static cast.

Template Parameters
TType of any
Returns
The moved any object

◆ operator=()

any & matador::any::operator= ( any  s)
inline

Assignment operator.

Parameters
sany object to be assigned
Returns
Reference to assigned any

◆ type_index()

std::type_index matador::any::type_index ( ) const
inline

Get the type index of an any object.

Get the type index of an any object. If any doesn't hold a value a logic_error is thrown.

Exceptions
std::logic_error
Returns
The type_index of the underlying type

Friends And Related Symbol Documentation

◆ swap

void swap ( any s,
any r 
)
friend

Allow swapping of any objects.

Parameters
sRight hand any to swap
rleft hand any to swap

The documentation for this class was generated from the following file:
  • matador/utils/any.hpp