47class A {
public:
virtual ~A(){} };
48class B :
public A {
public:
void f(
bool verbose) {
if(verbose) std::cout <<
"\nB::f() called!\n"; } };
51int main(
int argc,
char* argv[] )
64 clp.
setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
71 <<
"\n*******************************************"
72 <<
"\n*** Basic test of Teuchos::dyn_cast<>() ***"
73 <<
"\n*******************************************\n";
77 if(verbose) std::cout <<
"\nTrying: dynamic_cast<C&>(a); [Should throw a std::bad_cast std::exception with very bad error message]\n";
78 C& c_from_an_a =
dynamic_cast<C&
>(a);
81 catch(
const std::bad_cast &e ) {
82 if(verbose) std::cout <<
"\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() <<
"\"\n";
85 if(verbose) std::cout <<
"\nTrying: Teuchos::dyn_cast<C>(a); [Should throw a std::bad_cast std::exception with a very good error message]\n";
88 catch(
const std::bad_cast &e ) {
89 if(verbose) std::cout <<
"\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() <<
"\"\n";
91 if(verbose) std::cout <<
"\nTrying: Teuchos::dyn_cast<B>(a).f(); [Should succeed and print \"B::f() called\"]\n";
93 if(verbose) std::cout <<
"\nAll tests check out!\n";
95 catch(
const std::exception &excpt ) {
97 std::cerr <<
"*** Caught standard std::exception : " << excpt.what() << std::endl;
102 std::cerr <<
"*** Caught an unknown std::exception\n";
Basic command line parser for input from (argc,argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Class that helps parse command line input arguments from (argc,argv[]) and set options.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
EParseCommandLineReturn
Return value for CommandLineProcessor::parse(). Note: These enums are all given non-negative values s...
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
Parse a command line.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
Initialize, finalize, and query the global MPI session.
T_To & dyn_cast(T_From &from)
Dynamic casting utility function meant to replace dynamic_cast<T&> by throwing a better documented er...
std::string Teuchos_Version()