Modules | |
| group | Utility functions for passing arrays into argument lists. |
| The purpose of this utility is to make passing arrays into argument lists easier. | |
| group | Template classes for testing assertions at compile time. |
| group | Utility code for replacing calls to exit() with macros that result in thrown exceptions. |
| group | Utility code for throwing exceptions and setting breakpoints. |
Classes | |
| class | Teuchos::ValueTypeConversionTraits< TypeTo, TypeFrom > |
| Default traits class for all conversions of value types. More... | |
| class | Teuchos::m_bad_cast |
| Exception class for bad cast. More... | |
| class | Teuchos::TypeNameTraits< T > |
Default traits class that just returns typeid(T).name(). More... | |
Defines | |
| #define | TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG) |
| Simple macro that catches and reports standard exceptions and other exceptions. | |
Functions | |
| template<class TypeTo, class TypeFrom> | |
| TypeTo | Teuchos::as (const TypeFrom &t) |
| Perform an debug-enabled checked conversion from one value type object to another. | |
| template<class TypeTo, class TypeFrom> | |
| TypeTo | Teuchos::asSafe (const TypeFrom &t) |
| Perform an always checked conversion from one value type object to another. | |
| template<class T_To, class T_From> | |
| T_To & | Teuchos::dyn_cast (T_From &from) |
Dynamic casting utility function meant to replace dynamic_cast<T&> by throwing a better documented error message. | |
| template<class T> | |
| const T & | Teuchos::getConst (T &t) |
| Return a constant reference to an object given a non-const reference. | |
| template<class TypeTo, class TypeFrom> | |
| TypeTo | Teuchos::implicit_cast (const TypeFrom &t) |
| Perform an implicit cast of concrete types with the casted object returned by value. | |
| template<class TypeTo, class TypeFrom> | |
| TypeTo & | Teuchos::implicit_ref_cast (TypeFrom &t) |
| Perform an implicit cast of reference types with a reference being returned. | |
| template<class TypeTo, class TypeFrom> | |
| TypeTo * | Teuchos::implicit_ptr_cast (TypeFrom *t) |
| Perform an implicit cast of pointer types with a pointer being returned. | |
| std::string | Teuchos::demangleName (const std::string &mangledName) |
| Demangle a C++ name if valid. | |
| template<typename T> | |
| std::string | Teuchos::typeName (const T &t) |
| Template function for returning the demangled name of an object. | |
|
|
Simple macro that catches and reports standard exceptions and other exceptions.
This macro should be used to write simple
int main(...) { bool verbose = true; bool success = true; try { ... } TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose,std::cerr,success); return ( success ? 0 : 1 ); }
Definition at line 57 of file Teuchos_StandardCatchMacros.hpp. |
|
||||||||||
|
Perform an debug-enabled checked conversion from one value type object to another. This function is used as:
TypeTo myConversion( const TypeFrom& a ) { return Teuchos::as<TypeTo>(a); }
This is just an interface function what calls the traits class
When debug checking is turned on (e.g. when the
For cases where the checking should always be done (i.e. to validate user data), use the Definition at line 118 of file Teuchos_as.hpp. |
|
||||||||||
|
Perform an always checked conversion from one value type object to another. This function is used as:
TypeTo mySafeConversion( const TypeFrom& a ) { return Teuchos::asSafe<TypeTo>(a); }
This is just an interface function what calls the traits class
This function always calls
For cases where the checking should only be done in a debug build, use the the Definition at line 158 of file Teuchos_as.hpp. |
|
||||||||||
|
Dynamic casting utility function meant to replace
Existing uses of the built-in
C &c = dynamic_cast<C&>(a); are easily replaced as:
C &c = dyn_cast<C>(a); and that is it. One could write a perl script to do this automatically.
This utility function is designed to cast an object reference of type Consider the following class hierarchy:
class A {}; class B : public A {}; class C : public A {}; Now consider the following program: int main( int argc, char* argv[] ) { B b; A &a = b; try { std::cout << "\nTrying: dynamic_cast<C&>(a);\n"; dynamic_cast<C&>(a); } catch( const std::bad_cast &e ) { std::cout << "\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() << "\"\n"; } try { std::cout << "\nTrying: Teuchos::dyn_cast<C>(a);\n"; Teuchos::dyn_cast<C>(a); } catch( const std::bad_cast &e ) { std::cout << "\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() << "\"\n"; } return 0; } The above program will print something that looks like (compiled with g++ for example):
Trying: dynamic_cast<C&>(a); Caught std::bad_cast std::exception e where e.what() = "St8bad_cast" Trying: Teuchos::dyn_cast<C>(a); Caught std::bad_cast std::exception e where e.what() = "../../../../packages/teuchos/src/Teuchos_dyn_cast.cpp:46: true: dyn_cast<1C>(1A) : Error, the object with the concrete type '1B' (passed in through the interface type '1A') does not support the interface '1C' and the dynamic cast failed!"
The above program shows that the standard implementation of
Note that this function is inlined and does not incur any significant runtime performance penalty over the raw Definition at line 155 of file Teuchos_dyn_cast.hpp. |
|
||||||||||
|
Return a constant reference to an object given a non-const reference. This function just provides a shorthand notation for const_cast<const T&>(t) getCost(t) Definition at line 48 of file Teuchos_getConst.hpp. |
|
||||||||||
|
Perform an implicit cast of concrete types with the casted object returned by value. This function is used as:
TypeTo myCast( const TypeFrom& a ) { return Teuchos::implicit_cast<TypeTo>(a); }
This function will only compile for types where an implicit conversion from objects of type
This function is especially helpful when one needs to be careful of what specific type is passed in as a formal argument to a function and in comparing values. In particular, using this function is far safer than using Definition at line 68 of file Teuchos_implicit_cast.hpp. |
|
||||||||||
|
Perform an implicit cast of reference types with a reference being returned. This function is used as:
TypeTo& myPtrCast( TypeFrom &ref1 )
{
return Teuchos::implicit_ref_cast<TypeTo>(ref1);
}
This function will only compile for types where an implicit conversion from references of type
Note that this is a weaker operation than a Definition at line 103 of file Teuchos_implicit_cast.hpp. |
|
||||||||||
|
Perform an implicit cast of pointer types with a pointer being returned. This function is used as:
TypeTo* myPtrCast( TypeFrom *ptr1 )
{
return Teuchos::implicit_ptr_cast<TypeTo>(ptr1);
}
This function will only compile for types where an implicit conversion from pointers of type
Note that this is a weaker operation than a Definition at line 137 of file Teuchos_implicit_cast.hpp. |
|
|
Demangle a C++ name if valid.
The name must have come from Definition at line 40 of file Teuchos_TypeNameTraits.cpp. |
|
||||||||||
|
Template function for returning the demangled name of an object.
Definition at line 71 of file Teuchos_TypeNameTraits.hpp. |
1.3.9.1