82     << 
"\n*** Testing iterators and accessors for ptr = " << ptr
 
   87   const int size = ptr.size();
 
   92     out << 
"\nChecking ++itr and < ...\n";
 
   93     ArrayRCP<T> itr = 
ptr;
 
   94     for( 
int i = 0; itr < ptr+
size; ++i, ++itr )
 
   99     out << 
"\nChecking itr++ and <= ...\n";
 
  100     ArrayRCP<T> itr = 
ptr;
 
  101     for( 
int i = 0; itr <= ptr+size-1; ++i, itr++ )
 
  106     out << 
"\nChecking itr+=1 and != ...\n";
 
  107     ArrayRCP<T> itr = 
ptr;
 
  108     for( 
int i = 0; itr != ptr+
size; ++i, itr+=1 )
 
  113     out << 
"\nChecking itr=itr+1 and == ...\n";
 
  114     ArrayRCP<T> itr = 
ptr;
 
  115     for( 
int i = 0; !( itr == ptr+
size ); ++i, itr=itr+1 )
 
  122     out << 
"\nChecking --itr and >= ...\n";
 
  123     ArrayRCP<T> itr = ptr+size-1;
 
  124     for( 
int i = size-1; itr >= 
ptr; --i, --itr )
 
  129     out << 
"\nChecking itr-- and > ...\n";
 
  130     ArrayRCP<T> itr = ptr+size-1;
 
  131     for( 
int i = size-1; itr+1 > 
ptr; i--, itr-- )
 
  136     out << 
"\nChecking itr-=1 and != ...\n";
 
  137     ArrayRCP<T> itr = ptr+size-1;
 
  138     for( 
int i = size-1; itr+1 != 
ptr; i--, itr-=1 )
 
  143     out << 
"\nChecking itr=itr-1 and == ...\n";
 
  144     ArrayRCP<T> itr = ptr+size-1;
 
  145     for( 
int i = size-1; !( itr+1 == 
ptr ); i--, itr=itr-1 )
 
  152     out << 
"\nChecking ptr.end() - ptr.begin() == ptr.size() ...\n";
 
  159     out << 
"\nChecking iterator ++itr and < ...\n";
 
  160     typename ArrayRCP<T>::const_iterator itr = ptr.begin();
 
  161     for( 
int i = 0; itr < ptr.end(); ++i, ++itr )
 
  166     out << 
"\nChecking iterator itr++ and <= ...\n";
 
  167     typename ArrayRCP<T>::const_iterator itr = ptr.begin();
 
  168     for( 
int i = 0; itr <= ptr.end()-1; ++i, itr++ )
 
  173     out << 
"\nChecking iterator itr+=1 and != ...\n";
 
  174     typename ArrayRCP<T>::const_iterator itr = ptr.begin();
 
  175     for( 
int i = 0; itr != ptr.end(); ++i, itr+=1 )
 
  180     out << 
"\nChecking iterator itr=itr+1 and == ...\n";
 
  181     typename ArrayRCP<T>::const_iterator itr = ptr.begin();
 
  182     for( 
int i = 0; !( itr == ptr.end() ); ++i, itr=itr+1 )
 
  189     out << 
"\nChecking iterator --itr and >= ...\n";
 
  190     typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
 
  191     for( 
int i = size-1; itr >= ptr.begin(); --i, --itr )
 
  196     out << 
"\nChecking iterator itr-- and > ...\n";
 
  197     typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
 
  198     for( 
int i = size-1; itr+1 > ptr.begin(); i--, itr-- )
 
  203     out << 
"\nChecking iterator itr-=1 and != ...\n";
 
  204     typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
 
  205     for( 
int i = size-1; itr+1 != ptr.begin(); i--, itr-=1 )
 
  210     out << 
"\nChecking iterator itr=itr-1 and == ...\n";
 
  211     typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
 
  212     for( 
int i = size-1; !( itr+1 == ptr.begin() ); i--, itr=itr-1 )
 
  236   using Teuchos::arcp_const_cast;
 
  239   bool success = 
true, result;
 
  243     << 
"\n*** Testing ptr = " << ptr
 
  248   const int n = ptr.size();
 
  251     out << 
"\nInitializing data ...\n";
 
  252     for( 
int i = 0; i < 
n; ++i )
 
  260   if (!result) success = 
false;
 
  263   out << 
"\nTest const casting ...\n";
 
  267     const ArrayRCP<const T> cptr2 = 
ptr;
 
  273   out << 
"\nTest views ...\n";
 
  277     out << 
"\nTest full non-const subview ...\n";
 
  278     const ArrayView<T> av2 = 
ptr(0,n);
 
  283     out << 
"\nTest full shorthand non-const subview ...\n";
 
  284     const ArrayView<T> av2 = 
ptr();
 
  289     out << 
"\nTest full const subview ...\n";
 
  290     const ArrayView<const T> cav2 = ptr.getConst()(0,
n);
 
  295     out << 
"\nTest full non-const to const subview ...\n";
 
  296     const ArrayView<const T> cav2 = 
ptr(0,n);
 
  301     out << 
"\nTest full short-hand const subview ...\n";
 
  302     const ArrayView<const T> cav2 = ptr.getConst()();
 
  307     out << 
"\nTest implicit conversion from ArrayRCP<T> to ArrayView<T> ...\n";
 
  308     const ArrayView<T> av2 = 
ptr();
 
  313     out << 
"\nTest implicit conversion from ArrayRCP<const T> to ArrayView<const T> ...\n";
 
  314     const ArrayView<const T> av2 = ptr.getConst()();
 
  319     out << 
"\nTest almost implicit conversion from ArrayRCP<T> to ArrayView<const T> ...\n";
 
  320     const ArrayView<const T> av2 = 
ptr();
 
  325     out << 
"\nTest implicit conversion from ArrayRCP<T> to ArrayRCP<const T> ...\n";
 
  326     const ArrayRCP<const T> ptr2 = 
ptr;
 
  331     out << 
"\nTest clone of ArrayView<T> to ArrayRCP<T> ...\n";
 
  332     const ArrayRCP<T> ptr2 = Teuchos::arcpClone<T>(
ptr());
 
  337     out << 
"\nTest clone of ArrayPtr<const T> to ArrayRCP<T> ...\n";
 
  338     const ArrayRCP<T> ptr2 = Teuchos::arcpClone<T>(ptr.getConst()());
 
  342     out << 
"\nTest extra data ...\n";
 
  343     ArrayRCP<T> ptr2 = arcp<T>(
n);
 
  344     Teuchos::set_extra_data( as<int>(1), 
"int", Teuchos::inOutArg(ptr2) );
 
  358 int main( 
int argc, 
char* argv[] )
 
  369   using Teuchos::arcp_reinterpret_cast;
 
  371   bool success = 
true, result;
 
  380     int num_doubles = 10;
 
  381     CommandLineProcessor clp(
false); 
 
  382     clp.setOption( 
"num-ints", &num_ints, 
"Number of ints to allocate space for" );
 
  383     clp.setOption( 
"num-doubles", &num_doubles, 
"Number of doubles to allocate space for" );
 
  384     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
 
  385     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
 
  386       *out << 
"\nEnd Result: TEST FAILED" << std::endl;
 
  390     const int sizeOfDouble = 
sizeof(double);
 
  391     const int sizeOfInt = 
sizeof(int);
 
  393     const int total_bytes = num_doubles*sizeOfDouble + num_ints*sizeOfInt;
 
  397     *out << 
"\nTesting basic ArrayRCP functionality ...\n";
 
  400       char_ptr1 = arcp<char>(total_bytes);
 
  402     *out << 
"\nchar_ptr1 = " << char_ptr1 << 
"\n";
 
  411     if (!result) success = 
false;
 
  416     *out << 
"\nchar_ptr2 = " << char_ptr2 << 
"\n";
 
  425       char_ptr2b(char_ptr1); 
 
  427     *out << 
"\nchar_ptr2b = " << char_ptr2b << 
"\n";
 
  436     if (!result) success = 
false;
 
  446       char_ptr3 = char_ptr1.persistingView(total_bytes/2,total_bytes/2);
 
  453     if (!result) success = 
false;
 
  455     *out << 
"\nchar_ptr3 = " << char_ptr3 << 
"\n";
 
  457     *out << 
"\nBreak up char_ptr1 into views of double and int data\n";
 
  462       char_ptr1.persistingView(offset,sizeOfDouble*num_doubles)
 
  465     *out << 
"\ndouble_ptr1 = " << double_ptr1 << 
"\n";
 
  472     if (!result) success = 
false;
 
  474     offset += sizeOfDouble*num_doubles;
 
  477       char_ptr1.persistingView(offset,sizeOfInt*num_ints)
 
  480     *out << 
"\nint_ptr1 = " << int_ptr1 << 
"\n";
 
  487     if (!result) success = 
false;
 
  489     *out << 
"\nCreating a constant view of double_ptr1\n";
 
  491     ArrayRCP<const double>
 
  492       double_ptr2 = double_ptr1.
getConst();
 
  495     if (!result) success = 
false;
 
  497 #ifdef SHOW_COMPILE_FAILURE_1 
  501     for( 
int i = 0; i < double_ptr2.size(); ++i ) {
 
  502       double_ptr2[i] = 1.0; 
 
  506     *out << 
"\nCreating an array of RCP objects!\n";
 
  508     ArrayRCP<RCP<double> >
 
  509       rcp_ptr1 = arcp<RCP<double> >(num_doubles);
 
  511     for( 
int i = 0; i < num_doubles; ++i )
 
  512       rcp_ptr1[i] = 
rcp(
new double(i));
 
  515     if (!result) success = 
false;
 
  517     *out << 
"\nCreating a const view of rcp_ptr1\n";
 
  519     ArrayRCP<const RCP<double> >
 
  523     if (!result) success = 
false;
 
  525     *out << 
"\nCreating an ARCP<double*> object doubleptr_ptr1 and dynamically allocation each element\n";
 
  528       doubleptr_ptr1 = arcp<double*>(total_bytes);
 
  530     for( 
int i = 0; i < doubleptr_ptr1.size(); ++i )
 
  531       doubleptr_ptr1[i] = 
new double(i);
 
  534     if (!result) success = 
false;
 
  536     *out << 
"\nCreating an ARCP<double*const> view of a doubleptr_ptr1\n";
 
  538     ArrayRCP<double*const>
 
  539       doubleptr_ptr2 = doubleptr_ptr1.
getConst();
 
  542     if (!result) success = 
false;
 
  544 #ifdef SHOW_COMPILE_FAILURE_2 
  548     for( 
int i = 0; i < doubleptr_ptr2.size(); ++i ) {
 
  549       *doubleptr_ptr2[i] = 1.0; 
 
  550       doubleptr_ptr2[i] = NULL; 
 
  554     *out << 
"\nCreating an ARCP<const double * const> view of a doubleptr_ptr1\n";
 
  556     ArrayRCP<const double*const>
 
  557       doubleptr_ptr3 = Teuchos::arcp_implicit_cast<
const double*
const>(doubleptr_ptr1);
 
  560     if (!result) success = 
false;
 
  562 #ifdef SHOW_COMPILE_FAILURE_3 
  566     for( 
int i = 0; i < doubleptr_ptr3.size(); ++i ) {
 
  567       *doubleptr_ptr3[i] = 1.0; 
 
  568       doubleptr_ptr3[i] = NULL; 
 
  572     for( 
int i = 0; i < doubleptr_ptr1.size(); ++i )
 
  573       delete doubleptr_ptr1[i];
 
  575     *out << 
"\nWrapping RCP<std::vector<T> > objects as ArrayRCP objects ...\n";
 
  580         vchar_ptr1 = 
arcp(
rcp(
new std::vector<char>(total_bytes)));
 
  582       *out << 
"\nvchar_ptr1 = " << vchar_ptr1 << 
"\n";
 
  585       if (!result) success = 
false;
 
  587       ArrayRCP<const char> vchar_ptr2 = vchar_ptr1;
 
  589       *out << 
"\nvchar_ptr2 = " << vchar_ptr2 << 
"\n";
 
  592       if (!result) success = 
false;
 
  605     *out << 
"\nWrapping RCP<ARray<T> > objects as ArrayRCP objects ...\n";
 
  612       *out << 
"\nvchar_ptr1 = " << vchar_ptr1 << 
"\n";
 
  615       if (!result) success = 
false;
 
  630     *out << 
"\nAll tests for ArrayRCP seem to check out!\n";
 
  636     *out << 
"\nEnd Result: TEST PASSED" << std::endl; 
 
  638   return ( success ? 0 : 1 );
 
bool test_ArrayRCP(const Teuchos::ArrayRCP< T > &ptr, Teuchos::FancyOStream &out)
 
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
 
RCP< const T > getConst() const 
Return an RCP<const T> version of *this. 
 
ArrayRCP< T > arcp(const RCP< Array< T > > &v)
Wrap an RCP<Array<T> > object as an ArrayRCP<T> object. 
 
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
 
Initialize, finalize, and query the global MPI session. 
 
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*. 
 
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated. 
 
Utilities to make writing tests easier. 
 
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
 
#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. 
 
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2. 
 
std::string Teuchos_Version()
 
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator. 
 
TypeTo as(const TypeFrom &t)
Convert from one value type to another. 
 
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer. 
 
int main(int argc, char *argv[])
 
Templated array class derived from the STL std::vector. 
 
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0.... 
 
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
 
Basic command line parser for input from (argc,argv[]) 
 
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*. 
 
Smart reference counting pointer class for automatic garbage collection. 
 
#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 ...
 
RCP< basic_FancyOStream< CharT, Traits > > tab(const RCP< basic_FancyOStream< CharT, Traits > > &out, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
Create a tab for an RCP-wrapped basic_FancyOStream object to cause the indentation of all output auto...
 
bool test_ArrayRCP_iterators(const Teuchos::ArrayRCP< T > &ptr, Teuchos::FancyOStream &out)
 
Class that helps parse command line input arguments from (argc,argv[]) and set options. 
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call...
 
Reference-counted smart pointer for managing arrays.