Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos::any Class Reference

Modified boost::any class, which is a container for a templated value. More...

#include <Teuchos_any.hpp>

Public Member Functions

 any ()
 Empty constructor.
template<typename ValueType>
 any (ValueType &&value)
 Templated constructor.
 any (const any &other)
 Copy constructor.
 any (any &&other)
 Move constructor.
 ~any ()
 Destructor.
anyswap (any &rhs)
 Method for swapping the contents of two any classes.
template<typename ValueType>
anyoperator= (const ValueType &rhs)
 Copy the value rhs.
anyoperator= (const any &rhs)
 Copy the value held in rhs.
anyoperator= (any &&other)
 Move-assignment operator.
TEUCHOS_DEPRECATED bool empty () const
 Return true if nothing is being stored.
bool has_value () const
 Checks whether the object contains a value.
const std::type_info & type () const
 Return the type of value being stored.
std::string typeName () const
 Return the name of the type.
bool same (const any &other) const
 Return if two any objects are the same or not.
void print (std::ostream &os) const
 Print this value to the output stream os.

(Note that these are not member symbols.)

template<typename ValueType>
ValueType & any_cast (any &operand)
 Used to extract the templated value held in Teuchos::any to a given value type.
template<typename ValueType>
const ValueType & any_cast (const any &operand)
 Used to extract the const templated value held in Teuchos::any to a given const value type.
template<typename ValueType>
ValueType & any_ref_cast (any &operand)
 Keep the convenient behavior of Teuchos::any_cast w.r.t. references, but don't confuse it with the behavior for C++17 std::any_cast.
std::string toString (const any &rhs)
 Converts the value in any to a std::string.
bool operator== (const any &a, const any &b)
 Returns true if two any objects have the same value.
bool operator!= (const any &a, const any &b)
 Returns true if two any objects do not have the same value.
std::ostream & operator<< (std::ostream &os, const any &rhs)
 Writes "any" input rhs to the output stream os.
void swap (Teuchos::any &a, Teuchos::any &b)
 Special swap for other code to find via Argument Dependent Lookup.
template<typename T>
T & make_any_ref (any &rhs)
 Default constructs a new T value and returns a reference to it.

Detailed Description

Modified boost::any class, which is a container for a templated value.

Definition at line 122 of file Teuchos_any.hpp.

Constructor & Destructor Documentation

◆ any() [1/4]

Teuchos::any::any ( )
inline

Empty constructor.

Definition at line 126 of file Teuchos_any.hpp.

◆ any() [2/4]

template<typename ValueType>
Teuchos::any::any ( ValueType && value)
inlineexplicit

Templated constructor.

Definition at line 132 of file Teuchos_any.hpp.

◆ any() [3/4]

Teuchos::any::any ( const any & other)
inline

Copy constructor.

Definition at line 137 of file Teuchos_any.hpp.

◆ any() [4/4]

Teuchos::any::any ( any && other)
inline

Move constructor.

Definition at line 142 of file Teuchos_any.hpp.

◆ ~any()

Teuchos::any::~any ( )
inline

Destructor.

Definition at line 147 of file Teuchos_any.hpp.

Member Function Documentation

◆ swap()

any & Teuchos::any::swap ( any & rhs)
inline

Method for swapping the contents of two any classes.

Definition at line 153 of file Teuchos_any.hpp.

◆ operator=() [1/3]

template<typename ValueType>
any & Teuchos::any::operator= ( const ValueType & rhs)
inline

Copy the value rhs.

Definition at line 161 of file Teuchos_any.hpp.

◆ operator=() [2/3]

any & Teuchos::any::operator= ( const any & rhs)
inline

Copy the value held in rhs.

Definition at line 168 of file Teuchos_any.hpp.

◆ operator=() [3/3]

any & Teuchos::any::operator= ( any && other)
inline

Move-assignment operator.

Definition at line 175 of file Teuchos_any.hpp.

◆ empty()

TEUCHOS_DEPRECATED bool Teuchos::any::empty ( ) const
inline

Return true if nothing is being stored.

Definition at line 186 of file Teuchos_any.hpp.

◆ has_value()

bool Teuchos::any::has_value ( ) const
inline

Checks whether the object contains a value.

Definition at line 192 of file Teuchos_any.hpp.

◆ type()

const std::type_info & Teuchos::any::type ( ) const
inline

Return the type of value being stored.

Definition at line 195 of file Teuchos_any.hpp.

◆ typeName()

std::string Teuchos::any::typeName ( ) const
inline

Return the name of the type.

Definition at line 201 of file Teuchos_any.hpp.

◆ same()

bool Teuchos::any::same ( const any & other) const
inline

Return if two any objects are the same or not.

Warning
This function with throw an exception if operator== can't be applied to the held type!

Definition at line 210 of file Teuchos_any.hpp.

◆ print()

void Teuchos::any::print ( std::ostream & os) const
inline

Print this value to the output stream os.

Warning
This function with throw an exception if the held type can't be printed via operator<< !

Definition at line 226 of file Teuchos_any.hpp.

◆ any_cast() [1/2]

template<typename ValueType>
ValueType & any_cast ( any & operand)
related

Used to extract the templated value held in Teuchos::any to a given value type.

Note
  • If the templated value type and templated type are not the same then a bad_any_cast is thrown.
  • If the dynamic cast fails, then a Teuchos::bad_any_cast std::exception is thrown.

Definition at line 327 of file Teuchos_any.hpp.

◆ any_cast() [2/2]

template<typename ValueType>
const ValueType & any_cast ( const any & operand)
related

Used to extract the const templated value held in Teuchos::any to a given const value type.

Note
  • If the templated value type and templated type are not the same then a bad_any_cast is thrown.
  • If the dynamic cast fails, then a logic_error is thrown.

Definition at line 363 of file Teuchos_any.hpp.

◆ any_ref_cast()

template<typename ValueType>
ValueType & any_ref_cast ( any & operand)
related

Keep the convenient behavior of Teuchos::any_cast w.r.t. references, but don't confuse it with the behavior for C++17 std::any_cast.

Note
In C++17, one must use std::any_cast<T&> to get a reference. This function will ensure that uses of Teuchos::any_ref_cast<T> are consciously replaced with std::any_cast<T&> when C++17 is used.

Definition at line 396 of file Teuchos_any.hpp.

◆ toString()

std::string toString ( const any & rhs)
related

Converts the value in any to a std::string.

Warning
This function with throw an exception if the held type can't be printed via operator<< !

Definition at line 406 of file Teuchos_any.hpp.

◆ operator==()

bool operator== ( const any & a,
const any & b )
related

Returns true if two any objects have the same value.

Warning
This function with throw an exception if operator== can't be applied to the held type!

Definition at line 418 of file Teuchos_any.hpp.

◆ operator!=()

bool operator!= ( const any & a,
const any & b )
related

Returns true if two any objects do not have the same value.

Warning
This function with throw an exception if operator== can't be applied to the held type!

Definition at line 428 of file Teuchos_any.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
const any & rhs )
related

Writes "any" input rhs to the output stream os.

Warning
This function with throw an exception if the held type can't be printed via operator<< !

Definition at line 438 of file Teuchos_any.hpp.

◆ swap()

void swap ( Teuchos::any & a,
Teuchos::any & b )
related

Special swap for other code to find via Argument Dependent Lookup.

Definition at line 447 of file Teuchos_any.hpp.

◆ make_any_ref()

template<typename T>
T & make_any_ref ( any & rhs)
related

Default constructs a new T value and returns a reference to it.

Definition at line 455 of file Teuchos_any.hpp.


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