RobotsIO
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
RobotsIO::Utils::any Class Reference

#include <any.h>

Public Member Functions

 any () noexcept
 
 any (const any &other)
 
 any (any &&other) noexcept
 
template<typename ValueType >
 any (const ValueType &value)
 
template<typename ValueType >
 any (ValueType &&value, typename std::enable_if<!std::is_same< any &, ValueType >::value >::type *=0, typename std::enable_if<!std::is_const< ValueType >::value >::type *=0)
 
 ~any () noexcept
 
anyoperator= (const any &rhs)
 
anyoperator= (any &&rhs) noexcept
 
template<class ValueType >
anyoperator= (ValueType &&rhs)
 
void reset () noexcept
 
anyswap (any &rhs) noexcept
 
bool has_value () const noexcept
 
const std::type_info & type () const noexcept
 

Friends

template<typename ValueType >
ValueType * any_cast (any *) noexcept
 

Detailed Description

The class any describes a type-safe container for single values of any type. An object of class any stores an instance of any type that satisfies the constructor requirements or is empty, and this is referred to as the state of the class any object. The stored instance is called the contained object. Two states are equivalent if they are either both empty or if both are not empty and if the contained objects are equivalent. The non-member any_cast functions provide type-safe access to the contained object.

Definition at line 75 of file any.h.

Constructor & Destructor Documentation

◆ any() [1/5]

RobotsIO::Utils::any::any ( )
inlinenoexcept

Constructs an empty object.

Definition at line 81 of file any.h.

◆ any() [2/5]

RobotsIO::Utils::any::any ( const any other)
inline

Copies content of other into a new instance, so that any content is equivalent in both type and value to those of other prior to the constructor call, or empty if other is empty.

Definition at line 91 of file any.h.

◆ any() [3/5]

RobotsIO::Utils::any::any ( any &&  other)
inlinenoexcept

Moves content of other into a new instance, so that any content is equivalent in both type and value to those of other prior to the constructor call, or empty if other is empty.

Definition at line 101 of file any.h.

◆ any() [4/5]

template<typename ValueType >
RobotsIO::Utils::any::any ( const ValueType &  value)
inline

Constructs an object with initial content an object of type std::decay_t<ValueType>, direct-initialized from std::forward<ValueType>(value). If std::is_copy_constructible<std::decay_t<ValueType>>::value is false, the program is ill-formed.

Definition at line 114 of file any.h.

◆ any() [5/5]

template<typename ValueType >
RobotsIO::Utils::any::any ( ValueType &&  value,
typename std::enable_if<!std::is_same< any &, ValueType >::value >::type = 0,
typename std::enable_if<!std::is_const< ValueType >::value >::type = 0 
)
inline

Constructs an object with initial content an object of type std::decay_t<ValueType>, direct-initialized from std::forward<ValueType>(value). If std::is_copy_constructible<std::decay_t<ValueType>>::value is false, the program is ill-formed.

Definition at line 125 of file any.h.

◆ ~any()

RobotsIO::Utils::any::~any ( )
inlinenoexcept

Destruct the object.

Definition at line 133 of file any.h.

Member Function Documentation

◆ has_value()

bool RobotsIO::Utils::any::has_value ( ) const
inlinenoexcept

Checks whether the object contains a value.

Returns
true if instance contains a value, otherwise false.

Definition at line 208 of file any.h.

◆ operator=() [1/3]

any & RobotsIO::Utils::any::operator= ( any &&  rhs)
inlinenoexcept

Assigns contents to the contained value. Assigns by moving the state of rhs, as if by any(std::move(rhs)).swap(*this). rhs is left in a valid but unspecified state after the assignment.

Parameters
rhsobject whose contained value to assign

Definition at line 159 of file any.h.

◆ operator=() [2/3]

any & RobotsIO::Utils::any::operator= ( const any rhs)
inline

Assigns contents to the contained value. Assigns by copying the state of rhs, as if by any(rhs).swap(*this).

Parameters
rhsobject whose contained value to assign

Definition at line 145 of file any.h.

◆ operator=() [3/3]

template<class ValueType >
any & RobotsIO::Utils::any::operator= ( ValueType &&  rhs)
inline

Assigns contents to the contained value. Assigns the type and value of rhs, as if by any(std::forward<ValueType>(rhs)).swap(*this). This overload only participates in overload resolution if std::decay_t<ValueType> is not the same type as any and std::is_copy_constructible_v<std::decay_t<ValueType>> is true.

Parameters
rhsobject whose contained value to assign

Definition at line 176 of file any.h.

◆ reset()

void RobotsIO::Utils::any::reset ( )
inlinenoexcept

If not empty, destroys the contained object.

Definition at line 186 of file any.h.

◆ swap()

any & RobotsIO::Utils::any::swap ( any rhs)
inlinenoexcept

Swaps the content of two any objects.

Parameters
otherobject to swap with

Definition at line 197 of file any.h.

◆ type()

const std::type_info & RobotsIO::Utils::any::type ( ) const
inlinenoexcept

Queries the contained type.

The typeid of the contained value if instance is non-empty, otherwise typeid(void).

Definition at line 219 of file any.h.

Friends And Related Function Documentation

◆ any_cast

template<typename ValueType >
ValueType * any_cast ( any operand)
friend

Performs type-safe access to the contained object.

Throws blf::any::bad_any_cast if the typeid of the requested ValueType does not match that of the contents of operand.

Parameters
operandtarget any object

Definition at line 322 of file any.h.