54 int 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);
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 );
Null reference error exception class.
Ptr< T > inOutArg(T &arg)
create a non-persisting (required or optional) input/output argument for a function call...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Ptr< T > optInArg(T &arg)
create a non-persisting non-const optional input argument for a function call.
Initialize, finalize, and query the global MPI session.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
Ptr< T > ptrFromRef(T &arg)
Create a pointer to a object from an object reference.
Ptr< T > inoutArg(T &arg)
create a non-persisting (required or optional) input/output argument for a function call...
std::string Teuchos_Version()
Exception class for bad cast.
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
int main(int argc, char *argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
Smart reference counting pointer class for automatic garbage collection.
Ptr< const T > constPtr(T &arg)
Create a pointer from a const object given a non-const object reference.
#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 ...
Ptr< T > outArg(T &arg)
create a non-persisting (required or optional) output argument for a function call.
Ptr< const T > constOptInArg(T &arg)
create a non-persisting const optional input argument for a function call.
Definition of Teuchos::as, for conversions between types.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...