54int main(
int argc,
char* argv[] ) {
58 using Teuchos::ptrFromRef;
59 using Teuchos::constPtr;
60 using Teuchos::outArg;
61 using Teuchos::inOutArg;
62 using Teuchos::inoutArg;
63 using Teuchos::optInArg;
64 using Teuchos::constOptInArg;
81 CommandLineProcessor clp(
false);
83 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
85 if ( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
86 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
92 *out <<
"\nTesting Teuchos::Ptr class ...\n";
97 *out <<
"\nNull a_ptr = " << a_ptr <<
"\n";
105 "Error, Ptr::operator*() on null Ptr should have thrown exception!" );
115 "Error, Ptr::operator->() on null Ptr should have thrown exception!" );
127 *out <<
"\nNon-null a_ptr = " << a_ptr <<
"\n";
137 Ptr<A> a_ptr2(a_ptr1);
161 Ptr<A> a_ptr = ptr(&a);
169 Ptr<A> a_ptr = ptrFromRef(a);
177 Ptr<const A> a_ptr = constPtr(a);
185 Ptr<A> a_ptr = outArg(a);
193 Ptr<A> a_ptr = inOutArg(a);
201 Ptr<A> a_ptr = inoutArg(a);
209 Ptr<const A> a_ptr = optInArg(a);
217 Ptr<const A> a_ptr = constOptInArg(a);
226 Ptr<A> a_ptr1 = c_ptr;
227 Ptr<A> a_ptr2 = Teuchos::ptr_implicit_cast<A>(c_ptr);
235 Ptr<E> e_ptr = Teuchos::ptr_static_cast<E>(d_ptr);
242 Ptr<const C> c_ptr1(&c);
243 Ptr<C> c_ptr2 = Teuchos::ptr_const_cast<C>(c_ptr1);
250 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<C>(a_ptr);
258 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<C>(a_ptr);
266 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<C>(a_ptr,
true);
275 Ptr<C> b2_ptr = Teuchos::ptr_dynamic_cast<C>(a_ptr,
true);
278 "If you get here then the test failed!" );
289 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
291 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
293 return ( success ? 0 : 1 );
Basic command line parser for input from (argc,argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
Definition of Teuchos::as, for conversions between types.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
Initialize, finalize, and query the global MPI session.
Null reference error exception class.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Smart reference counting pointer class for automatic garbage collection.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
Exception class for bad cast.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...
std::string Teuchos_Version()