22 int main(
int argc,
char* argv[] ) {
26 using Teuchos::ptrFromRef;
27 using Teuchos::constPtr;
28 using Teuchos::outArg;
29 using Teuchos::inOutArg;
30 using Teuchos::inoutArg;
31 using Teuchos::optInArg;
32 using Teuchos::constOptInArg;
49 CommandLineProcessor clp(
false);
51 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
53 if ( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
54 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
60 *out <<
"\nTesting Teuchos::Ptr class ...\n";
65 *out <<
"\nNull a_ptr = " << a_ptr <<
"\n";
73 "Error, Ptr::operator*() on null Ptr should have thrown exception!" );
83 "Error, Ptr::operator->() on null Ptr should have thrown exception!" );
95 *out <<
"\nNon-null a_ptr = " << a_ptr <<
"\n";
105 Ptr<A> a_ptr2(a_ptr1);
129 Ptr<A> a_ptr =
ptr(&a);
194 Ptr<A> a_ptr1 = c_ptr;
195 Ptr<A> a_ptr2 = Teuchos::ptr_implicit_cast<
A>(c_ptr);
203 Ptr<E> e_ptr = Teuchos::ptr_static_cast<
E>(d_ptr);
210 Ptr<const C> c_ptr1(&c);
211 Ptr<C> c_ptr2 = Teuchos::ptr_const_cast<
C>(c_ptr1);
218 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<
C>(a_ptr);
226 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<
C>(a_ptr);
234 Ptr<C> c_ptr = Teuchos::ptr_dynamic_cast<
C>(a_ptr,
true);
243 Ptr<C> b2_ptr = Teuchos::ptr_dynamic_cast<
C>(a_ptr,
true);
246 "If you get here then the test failed!" );
257 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
259 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
261 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...