Support Class Library
A set of tools providing classes and utility
Public Member Functions | Protected Attributes | List of all members
scl::utils::Any Class Reference

Class that can hold any value type (and change value type mid lifetime) More...

#include "Any.h"

Collaboration diagram for scl::utils::Any:
Collaboration graph
[legend]

Public Member Functions

template<class T >
 Any (T &&value)
 Move a value into an Any. More...
 
 Any (Any &&)=default
 
Anyoperator= (Any &&)=default
 
 Any ()=delete
 
 Any (const Any &)=delete
 
Anyoperator= (const Any &)=delete
 
template<class T >
Anyoperator= (T &&value)
 Assign a new value to this Any. More...
 
template<class U >
bool canCastTo () const
 Safely determines whether or not you can cast from the current value type to the one given as argument. More...
 
template<class U >
as () const
 Attempts to cast this Any. More...
 

Protected Attributes

std::unique_ptr< details::__any_baseimpl
 A PIMPL. More...
 
const std::type_info * ti
 The type_info of the current value type. More...
 

Detailed Description

Class that can hold any value type (and change value type mid lifetime)

Definition at line 60 of file Any.h.

Constructor & Destructor Documentation

◆ Any() [1/4]

template<class T >
scl::utils::Any::Any ( T &&  value)
inline

Move a value into an Any.

Template Parameters
Tbeing the given value type
Parameters
valuebeing the value to construct from

Definition at line 81 of file Any.h.

◆ Any() [2/4]

scl::utils::Any::Any ( Any &&  )
default

◆ Any() [3/4]

scl::utils::Any::Any ( )
delete

◆ Any() [4/4]

scl::utils::Any::Any ( const Any )
delete

Member Function Documentation

◆ as()

template<class U >
U scl::utils::Any::as ( ) const
inline

Attempts to cast this Any.

Template Parameters
Ubeing the type to cast to
Returns
the type safe value
Exceptions
scl::exceptions::InvalidAnyCastif if can't cast

Definition at line 122 of file Any.h.

◆ canCastTo()

template<class U >
bool scl::utils::Any::canCastTo ( ) const
inline

Safely determines whether or not you can cast from the current value type to the one given as argument.

Template Parameters
Ubeing the desired cast type
Returns
TRUE if it is the current value type, FALSE otherwise

Definition at line 111 of file Any.h.

◆ operator=() [1/3]

Any& scl::utils::Any::operator= ( Any &&  )
default

◆ operator=() [2/3]

Any& scl::utils::Any::operator= ( const Any )
delete

◆ operator=() [3/3]

template<class T >
Any& scl::utils::Any::operator= ( T &&  value)
inline

Assign a new value to this Any.

Template Parameters
Tbeing the new value type
Parameters
valuebeing the new value
Returns
a reference to this Any

Definition at line 98 of file Any.h.

Member Data Documentation

◆ impl

scl::utils::Any::impl
protected

A PIMPL.

Definition at line 66 of file Any.h.

◆ ti

scl::utils::Any::ti
protected

The type_info of the current value type.

Definition at line 72 of file Any.h.


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