Teuchos - Trilinos Tools Package  Version of the Day
Public Member Functions | Related Functions | List of all members
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. More...
 
template<typename ValueType >
 any (const ValueType &value)
 Templated constructor. More...
 
 any (const any &other)
 Copy constructor. More...
 
 ~any ()
 Destructor. More...
 
anyswap (any &rhs)
 Method for swapping the contents of two any classes. More...
 
template<typename ValueType >
anyoperator= (const ValueType &rhs)
 Copy the value rhs More...
 
anyoperator= (const any &rhs)
 Copy the value held in rhs More...
 
bool empty () const
 Return true if nothing is being stored. More...
 
const std::type_info & type () const
 Return the type of value being stored. More...
 
std::string typeName () const
 Return the name of the type. More...
 
bool same (const any &other) const
 Return if two any objects are the same or not. More...
 
void print (std::ostream &os) const
 Print this value to the output stream os More...
 

Related Functions

(Note that these are not member functions.)

template<typename ValueType >
ValueType & any_cast (any &operand)
 Used to extract the templated value held in Teuchos::any to a given value type. More...
 
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. More...
 
std::string toString (const any &rhs)
 Converts the value in any to a std::string. More...
 
bool operator== (const any &a, const any &b)
 Returns true if two any objects have the same value. More...
 
bool operator!= (const any &a, const any &b)
 Returns true if two any objects do not have the same value. More...
 
std::ostream & operator<< (std::ostream &os, const any &rhs)
 Writes "any" input rhs to the output stream os. More...
 

Detailed Description

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

Definition at line 86 of file Teuchos_any.hpp.

Constructor & Destructor Documentation

◆ any() [1/3]

Teuchos::any::any ( )
inline

Empty constructor.

Definition at line 90 of file Teuchos_any.hpp.

◆ any() [2/3]

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

Templated constructor.

Definition at line 96 of file Teuchos_any.hpp.

◆ any() [3/3]

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

Copy constructor.

Definition at line 101 of file Teuchos_any.hpp.

◆ ~any()

Teuchos::any::~any ( )
inline

Destructor.

Definition at line 106 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 112 of file Teuchos_any.hpp.

◆ operator=() [1/2]

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

Copy the value rhs

Definition at line 120 of file Teuchos_any.hpp.

◆ operator=() [2/2]

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

Copy the value held in rhs

Definition at line 127 of file Teuchos_any.hpp.

◆ empty()

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

Return true if nothing is being stored.

Definition at line 134 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 140 of file Teuchos_any.hpp.

◆ typeName()

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

Return the name of the type.

Definition at line 146 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.

Definition at line 152 of file Teuchos_any.hpp.

◆ print()

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

Print this value to the output stream os

Definition at line 165 of file Teuchos_any.hpp.

Friends And Related Function Documentation

◆ 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 265 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 301 of file Teuchos_any.hpp.

◆ toString()

std::string toString ( const any rhs)
related

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

Definition at line 309 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.

Definition at line 319 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.

Definition at line 327 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.

Definition at line 335 of file Teuchos_any.hpp.


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