Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ArrayRCPDecl.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42
43#ifndef TEUCHOS_ARRAY_RCP_DECL_HPP
44#define TEUCHOS_ARRAY_RCP_DECL_HPP
45
46
47#include "Teuchos_RCP.hpp"
48#include "Teuchos_Exceptions.hpp"
49#include "Teuchos_ArrayViewDecl.hpp"
50
51
52namespace Teuchos {
53
126template<class T>
127class ArrayRCP {
128public:
130
131
133 typedef Teuchos_Ordinal Ordinal;
134
137
140
142 typedef std::random_access_iterator_tag iterator_category;
143
145 typedef T* iterator_type;
146
148 typedef T value_type;
149
151 typedef T& reference;
152
154 typedef const T& const_reference;
155
157 typedef T* pointer;
158
160 typedef T* const_pointer;
161
163 typedef T element_type;
164
165#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
167 typedef ArrayRCP<T> iterator;
170#else
172 typedef T* iterator;
174 typedef const T* const_iterator;
175#endif
176
178
180
193 inline ArrayRCP( ENull null_arg = null );
194
217 bool has_ownership, const ERCPNodeLookup rcpNodeLookup = RCP_ENABLE_NODE_LOOKUP );
218
241 template<class Dealloc_T>
242 inline ArrayRCP( T* p, size_type lowerOffset, size_type size, Dealloc_T dealloc,
243 bool has_ownership );
244
260 inline explicit ArrayRCP( size_type size, const T& val = T() );
261
280 inline ArrayRCP(const ArrayRCP<T>& r_ptr);
281
292 inline ~ArrayRCP();
293
321 inline ArrayRCP<T>& operator=(const ArrayRCP<T>& r_ptr);
322
324
326
328 inline bool is_null() const;
329
337 inline T* operator->() const;
338
346 inline T& operator*() const;
347
353 inline T* get() const;
354
360 inline T* getRawPtr() const;
361
367 inline T& operator[](size_type offset) const;
368
370
372
381 inline ArrayRCP<T>& operator++();
382
391 inline ArrayRCP<T> operator++(int);
392
401 inline ArrayRCP<T>& operator--();
402
411 inline ArrayRCP<T> operator--(int);
412
421 inline ArrayRCP<T>& operator+=(size_type offset);
422
431 inline ArrayRCP<T>& operator-=(size_type offset);
432
445 inline ArrayRCP<T> operator+(size_type offset) const;
446
459 inline ArrayRCP<T> operator-(size_type offset) const;
460
462
464
475 inline iterator begin() const;
476
487 inline iterator end() const;
488
490
492
498 inline ArrayRCP<const T> getConst() const;
499
514
516
518
520 inline size_type lowerOffset() const;
521
523 inline size_type upperOffset() const;
524
529 inline size_type size() const;
530
532
534
549
555
560 inline ArrayView<T> operator()() const;
561
563
565
572 inline operator ArrayRCP<const T>() const;
573
575
577
582 inline void assign(size_type n, const T &val);
583
591 template<class Iter>
592 inline void assign(Iter first, Iter last);
593
599 inline void deepCopy(const ArrayView<const T>& av);
600
602 inline void resize(const size_type n, const T &val = T());
603
608 inline void clear();
609
611
613
625 inline ERCPStrength strength() const;
626
636 inline bool is_valid_ptr() const;
637
643 inline int strong_count() const;
644
650 inline int weak_count() const;
651
653 inline int total_count() const;
654
672 inline void set_has_ownership();
673
685 inline bool has_ownership() const;
686
707 inline T* release();
708
723 inline ArrayRCP<T> create_weak() const;
724
740 inline ArrayRCP<T> create_strong() const;
741
748 template<class T2>
749 inline bool shares_resource(const ArrayRCP<T2>& r_ptr) const;
750
752
754
758 inline const ArrayRCP<T>& assert_not_null() const;
759
766
776 inline const ArrayRCP<T>& assert_valid_ptr() const;
777
779
780private:
782 T *ptr_;
784 RCPNodeHandle node_;
786 size_type lowerOffset_;
788 size_type upperOffset_;
789
790 inline void debug_assert_not_null () const {
791#ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
793#endif
794 }
795
796 inline void
797 debug_assert_in_range (size_type lowerOffset_in,
798 size_type size_in) const
799 {
800 (void) lowerOffset_in;
801 (void) size_in;
802#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
803 assert_in_range (lowerOffset_in, size_in);
804#endif
805 }
806
807 inline void debug_assert_valid_ptr() const {
808#ifdef TEUCHOS_DEBUG
810#endif
811 }
812
813public:
814
815#ifndef DOXYGEN_COMPILE
816 // These constructors should be private but I have not had good luck making
817 // this portable (i.e. using friendship etc.) in the past
818 // This is a very bad breach of encapsulation that is needed since MS VC++
819 // 5.0 will not allow me to declare template functions as friends.
821 const RCPNodeHandle& node );
822 T* access_private_ptr() const;
823 RCPNodeHandle& nonconst_access_private_node();
824 const RCPNodeHandle& access_private_node() const;
825#endif
826
827};
828
829
837template<class T>
838class ArrayRCP<const T> {
839public:
840 typedef Teuchos_Ordinal Ordinal;
841 typedef Ordinal size_type;
842 typedef Ordinal difference_type;
843 typedef std::random_access_iterator_tag iterator_category;
844 typedef const T* iterator_type;
845 typedef const T value_type;
846 typedef const T& reference;
847 typedef const T& const_reference;
848 typedef const T* pointer;
849 typedef const T* const_pointer;
850 typedef const T element_type;
851
852#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
855#else
856 typedef const T* iterator;
857 typedef const T* const_iterator;
858#endif
859
860 inline ArrayRCP (ENull null_arg = null);
861 inline ArrayRCP (const T* p, size_type lowerOffset,
862 size_type size, bool has_ownership,
863 const ERCPNodeLookup rcpNodeLookup = RCP_ENABLE_NODE_LOOKUP);
864 template<class Dealloc_T>
865 inline ArrayRCP (const T* p, size_type lowerOffset, size_type size,
866 Dealloc_T dealloc, bool has_ownership);
867 inline explicit ArrayRCP (size_type size, const T& val = T ());
868 inline ArrayRCP (const ArrayRCP<const T>& r_ptr);
869 inline ~ArrayRCP();
870
871 inline ArrayRCP<const T>& operator= (const ArrayRCP<const T>& r_ptr);
872 inline bool is_null() const;
873 inline const T* operator->() const;
874 inline const T& operator*() const;
875 inline const T* get() const;
876 inline const T* getRawPtr() const;
877 inline const T& operator[] (size_type offset) const;
878
880 inline ArrayRCP<const T> operator++ (int);
882 inline ArrayRCP<const T> operator-- (int);
883 inline ArrayRCP<const T>& operator+= (size_type offset);
884 inline ArrayRCP<const T>& operator-= (size_type offset);
885 inline ArrayRCP<const T> operator+ (size_type offset) const;
886 inline ArrayRCP<const T> operator- (size_type offset) const;
887
888 inline iterator begin() const;
889 inline iterator end() const;
890
897 inline ArrayRCP<const T> persistingView (size_type lowerOffset, size_type size) const;
898
899 inline size_type lowerOffset() const;
900 inline size_type upperOffset() const;
901 inline size_type size() const;
902
903 inline ArrayView<const T> view (size_type lowerOffset, size_type size) const;
904 inline ArrayView<const T> operator() (size_type lowerOffset, size_type size) const;
905 inline ArrayView<const T> operator() () const;
906
907 inline void resize (const size_type n, const T& val = T ());
908 inline void clear ();
909
910 inline ERCPStrength strength() const;
911 inline bool is_valid_ptr() const;
912 inline int strong_count() const;
913 inline int weak_count() const;
914 inline int total_count() const;
915 inline void set_has_ownership();
916 inline bool has_ownership() const;
917 inline const T* release();
918 inline ArrayRCP<const T> create_weak() const;
919 inline ArrayRCP<const T> create_strong() const;
920
921 template<class T2>
922 inline bool shares_resource (const ArrayRCP<T2>& r_ptr) const;
923
924 inline const ArrayRCP<const T>& assert_not_null () const;
925 inline const ArrayRCP<const T>& assert_in_range (size_type lowerOffset, size_type size) const;
926 inline const ArrayRCP<const T>& assert_valid_ptr() const;
927
928private:
929 const T* ptr_; // NULL if this pointer is null
930 RCPNodeHandle node_; // NULL if this pointer is null
931 size_type lowerOffset_; // 0 if this pointer is null
932 size_type upperOffset_; // -1 if this pointer is null
933
934 inline void debug_assert_not_null() const {
935#ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
937#endif
938 }
939
940 inline void
941 debug_assert_in_range (size_type lowerOffset_in,
942 size_type size_in) const
943 {
944 (void) lowerOffset_in; (void) size_in;
945#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
946 assert_in_range (lowerOffset_in, size_in);
947#endif
948 }
949
950 inline void debug_assert_valid_ptr() const {
951#ifdef TEUCHOS_DEBUG
953#endif
954 }
955
956public:
957
958#ifndef DOXYGEN_COMPILE
959 // These constructors should be private but I have not had good luck making
960 // this portable (i.e. using friendship etc.) in the past
961 // This is a very bad breach of encapsulation that is needed since MS VC++
962 // 5.0 will not allow me to declare template functions as friends.
963 ArrayRCP (const T* p, size_type lowerOffset,
964 size_type size, const RCPNodeHandle& node);
965 const T* access_private_ptr() const;
966 RCPNodeHandle& nonconst_access_private_node();
967 const RCPNodeHandle& access_private_node() const;
968#endif
969};
970
971
980template<>
981class ArrayRCP<void> {
982public:
983 typedef Teuchos_Ordinal Ordinal;
984 typedef Ordinal size_type;
985 typedef Ordinal difference_type;
986 typedef std::random_access_iterator_tag iterator_category;
987 typedef void* iterator_type;
988 typedef void value_type;
990 // typedef T& reference; // these are not valid
992 // typedef const T& const_reference; // these are not valid
993 typedef void* pointer;
994 typedef void* const_pointer;
995 typedef void element_type;
996
998 inline ArrayRCP ();
999};
1000
1005template<>
1006class ArrayRCP<const void> {
1007public:
1008 typedef Teuchos_Ordinal Ordinal;
1009 typedef Ordinal size_type;
1010 typedef Ordinal difference_type;
1011 typedef std::random_access_iterator_tag iterator_category;
1012 typedef const void* iterator_type;
1013 typedef const void value_type;
1015 // typedef T& reference; // these are not valid
1017 // typedef const T& const_reference; // these are not valid
1018 typedef const void* pointer;
1019 typedef const void* const_pointer;
1020 typedef const void element_type;
1021
1023 inline ArrayRCP ();
1024};
1025
1026// 2008/09/22: rabartl: NOTE: I removed the TypeNameTraits<ArrayRCP<T> >
1027// specialization since I want to be able to print the type name of an
1028// ArrayRCP that does not have the type T fully defined!
1029
1030
1035template<typename T>
1037public:
1038 static ArrayRCP<T> getNull() { return null; }
1039};
1040
1041
1047template<class T>
1049 T* p,
1050 typename ArrayRCP<T>::size_type lowerOffset,
1051 typename ArrayRCP<T>::size_type size,
1052 bool owns_mem = true
1053 );
1054
1055
1061template<class T, class Dealloc_T>
1063 T* p,
1064 typename ArrayRCP<T>::size_type lowerOffset,
1065 typename ArrayRCP<T>::size_type size,
1066 Dealloc_T dealloc, bool owns_mem
1067 );
1068
1069
1080template<class T>
1082
1083
1097template<class T>
1099
1100
1105template<class T>
1107
1108
1119template<class T, class Embedded>
1122 T* p,
1123 typename ArrayRCP<T>::size_type lowerOffset,
1124 typename ArrayRCP<T>::size_type size,
1125 const Embedded &embedded,
1126 bool owns_mem = true
1127 );
1128
1129
1140template<class T, class Embedded>
1143 T* p,
1144 typename ArrayRCP<T>::size_type lowerOffset,
1145 typename ArrayRCP<T>::size_type size,
1146 const Embedded &embedded,
1147 bool owns_mem = true
1148 );
1149
1150
1162template<class T, class Embedded>
1165 T* p,
1166 typename ArrayRCP<T>::size_type lowerOffset,
1167 typename ArrayRCP<T>::size_type size,
1168 const Embedded &embedded,
1169 bool owns_mem = true
1170 );
1171
1172
1178template<class T>
1179ArrayRCP<T> arcp( const RCP<std::vector<T> > &v );
1180
1181
1187template<class T>
1188ArrayRCP<const T> arcp( const RCP<const std::vector<T> > &v );
1189
1190
1199template<class T>
1201
1202
1210template<class T>
1212
1213
1220template<class T>
1222
1223
1228template<class T>
1229bool is_null( const ArrayRCP<T> &p );
1230
1231
1236template<class T>
1237bool nonnull( const ArrayRCP<T> &p );
1238
1239
1244template<class T>
1245bool operator==( const ArrayRCP<T> &p, ENull );
1246
1247
1252template<class T>
1253bool operator!=( const ArrayRCP<T> &p, ENull );
1254
1255
1260template<class T1, class T2>
1261bool operator==( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1262
1263
1268template<class T1, class T2>
1269bool operator!=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1270
1271
1276template<class T1, class T2>
1277bool operator<( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1278
1279
1284template<class T1, class T2>
1285bool operator<=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1286
1287
1292template<class T1, class T2>
1293bool operator>( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1294
1295
1300template<class T1, class T2>
1301bool operator>=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1302
1303
1311template<class T>
1313operator-( const ArrayRCP<T> &p1, const ArrayRCP<T> &p2 );
1314
1315
1326template<class T2, class T1>
1327inline
1329
1330
1342template<class T2, class T1>
1344
1345
1362template<class T2, class T1>
1364
1365
1391template<class T2, class T1>
1392inline
1394
1395
1454template<class T1, class T2>
1456 const T1 &extra_data, const std::string& name,
1457 const Ptr<ArrayRCP<T2> > &p, EPrePostDestruction destroy_when = POST_DESTROY,
1458 bool force_unique = true );
1459
1460
1480template<class T1, class T2>
1481T1& get_extra_data( ArrayRCP<T2>& p, const std::string& name );
1482
1483
1509template<class T1, class T2>
1510const T1& get_extra_data( const ArrayRCP<T2>& p, const std::string& name );
1511
1512
1537template<class T1, class T2>
1538T1* get_optional_extra_data( ArrayRCP<T2>& p, const std::string& name );
1539
1540
1570template<class T1, class T2>
1571const T1* get_optional_extra_data( const ArrayRCP<T2>& p, const std::string& name );
1572
1573
1584template<class Dealloc_T, class T>
1585Dealloc_T& get_nonconst_dealloc( const ArrayRCP<T>& p );
1586
1587
1605template<class Dealloc_T, class T>
1606const Dealloc_T& get_dealloc( const ArrayRCP<T>& p );
1607
1608
1623template<class Dealloc_T, class T>
1624const Dealloc_T* get_optional_dealloc( const ArrayRCP<T>& p );
1625
1626
1648template<class Dealloc_T, class T>
1650
1651
1658template<class TOrig, class Embedded, class T>
1659const Embedded& getEmbeddedObj( const ArrayRCP<T>& p );
1660
1661
1668template<class TOrig, class Embedded, class T>
1670
1671
1679template<class T>
1680std::ostream& operator<<( std::ostream& out, const ArrayRCP<T>& p );
1681
1682
1683} // end namespace Teuchos
1684
1685
1686#endif // TEUCHOS_ARRAY_RCP_DECL_HPP
Reference-counted pointer class and non-member templated function implementations.
ArrayRCP< const T > getConst() const
Return const reference to the array.
ArrayRCP()
Default constructor; thows an exception.
Reference-counted smart pointer for managing arrays.
T1 * get_optional_extra_data(ArrayRCP< T2 > &p, const std::string &name)
Get a pointer to non-const extra data (if it exists) associated with a ArrayRCP object.
ArrayRCP< T > create_weak() const
Create a new weak reference from another (strong) reference.
T & reference
Type of a (nonconstant) reference to an array element.
Embedded & getNonconstEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(),...
ArrayRCP< T > arcpWithEmbeddedObjPostDestroy(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
void set_has_ownership()
Give this and other ArrayRCP<> objects ownership of the underlying referenced array to delete it.
T1 & get_extra_data(ArrayRCP< T2 > &p, const std::string &name)
Get a non-const reference to extra data associated with a ArrayRCP object.
size_type upperOffset() const
Return the upper offset to valid data.
ArrayRCP< T > & operator++()
Prefix increment of pointer (i.e. ++ptr).
const T & const_reference
Type of a (constant) reference to an array element.
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof.
Ordinal difference_type
Type representing the difference between two size_type values.
ArrayRCP< T > arcp(typename ArrayRCP< T >::size_type size)
Allocate a new array just given a dimension.
std::random_access_iterator_tag iterator_category
Category of ArrayRCP's iterator type.
bool has_ownership() const
Returns true if this has ownership of object pointed to by this->get() in order to deallocate it.
bool operator!=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare two ArrayRCP objects for inequality (by pointers).
Teuchos_Ordinal Ordinal
Integer index type used throughout ArrayRCP.
T * iterator
Nonconstant iterator type used if bounds checking is disabled.
ArrayRCP< T > arcpFromArrayView(const ArrayView< T > &av)
Get an ArrayRCP object out of an ArrayView object.
ArrayRCP< T > & operator+=(size_type offset)
Pointer integer increment (i.e. ptr+=offset).
ArrayRCP(ENull null_arg=null)
Default constructor; initialize to an empty array.
bool is_null() const
True if the underlying pointer is null, else false.
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*.
ArrayRCP< const T > getConst() const
Return object for only const access to data.
const Dealloc_T * get_optional_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying non-const deallocator object if it exists.
void set_extra_data(const T1 &extra_data, const std::string &name, const Ptr< ArrayRCP< T2 > > &p, EPrePostDestruction destroy_when=POST_DESTROY, bool force_unique=true)
Set extra data associated with a ArrayRCP object.
const Dealloc_T & get_dealloc(const ArrayRCP< T > &p)
Return a const reference to the underlying deallocator object.
T & operator*() const
Dereference the underlying object for the current pointer position.
const ArrayRCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
bool operator==(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare two ArrayRCP objects for equality (by pointers).
T * release()
Release the ownership of the underlying array.
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
bool operator>=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using >=.
void clear()
Resize to zero.
T value_type
Type of each array element.
T * get() const
Get the raw C++ pointer to the underlying object.
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*.
size_type size() const
The total number of entries in the array.
Dealloc_T * get_optional_nonconst_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying const deallocator object if it exists.
T & operator[](size_type offset) const
Random object access.
ArrayRCP< T > create_strong() const
Create a new strong RCP object from another (weak) RCP object.
ArrayRCP< T > arcp(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, Dealloc_T dealloc, bool owns_mem)
Wraps a preallocated array of data and uses a templated deallocation strategy object to define deleti...
void deepCopy(const ArrayView< const T > &av)
Deep copy the elements from one ArrayView object into this object.
const T1 & get_extra_data(const ArrayRCP< T2 > &p, const std::string &name)
Get a const reference to extra data associated with a ArrayRCP object.
bool shares_resource(const ArrayRCP< T2 > &r_ptr) const
Returns true if the smart pointers share the same underlying reference-counted object.
size_type lowerOffset() const
Return the lower offset to valid data.
ArrayRCP< T > operator-(size_type offset) const
Pointer integer decrement (i.e. ptr-offset).
ArrayRCP< T > arcpWithEmbeddedObj(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
const T * const_iterator
Constant iterator type used if bounds checking is disabled.
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
T element_type
Type of each array element.
bool operator<(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using <.
ArrayRCP< T > & operator--()
Prefix decrement of pointer (i.e. –ptr).
ArrayRCP< T > arcp(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, bool owns_mem=true)
Wraps a preallocated array of data with the assumption to call the array version of delete.
ArrayView< T > operator()() const
Return a nonpersisting view of *this.
ArrayView< T > view(size_type lowerOffset, size_type size) const
Return a nonpersisting view of a contiguous range of elements.
const ArrayRCP< T > & assert_in_range(size_type lowerOffset, size_type size) const
Throws NullReferenceError if this->get()==NULL orthis->get()!=NULL, throws RangeError if (lowerOffset...
std::ostream & operator<<(std::ostream &out, const ArrayRCP< T > &p)
Output stream inserter.
bool operator==(const ArrayRCP< T > &p, ENull)
Returns true if p.get()==NULL.
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
ArrayRCP< T > persistingView(size_type lowerOffset, size_type size) const
Return a persisting view of a contiguous range of elements.
bool is_valid_ptr() const
Return whether the underlying object pointer is still valid.
RCP< const std::vector< T > > get_std_vector(const ArrayRCP< const T > &ptr)
Get a const std::vector<T> object out of an ArrayRCP<const T> object that was created using the arcp(...
void resize(const size_type n, const T &val=T())
Resize and append new elements if necessary.
ArrayRCP< T > arcpCloneNode(const ArrayRCP< T > &a)
Allocate a new ArrayRCP object with a new RCPNode with memory pointing to the initial node.
ArrayRCP< T > & operator=(const ArrayRCP< T > &r_ptr)
Assignment operator: Makes *this reference the input array.
ArrayRCP< T > operator+(size_type offset) const
Pointer integer increment (i.e. ptr+offset).
ArrayRCP< T2 > arcp_reinterpret_cast_nonpod(const ArrayRCP< T1 > &p1, const T2 &val=T2())
Reinterpret cast of underlying ArrayRCP type from T1* to T2* where T2 is a non-POD (non-plain-old-dat...
T * iterator_type
Type of an ArrayRCP's iterator.
void assign(size_type n, const T &val)
Resize and assign n elements of val.
iterator begin() const
Return an iterator to beginning of the array of data.
T * operator->() const
Pointer (->) access to members of underlying object for current position.
~ArrayRCP()
Destructor, that decrements the reference count.
ERCPStrength strength() const
Strength of the pointer.
ArrayRCP< T > arcpClone(const ArrayView< const T > &v)
Allocate a new array by cloning data from an input array view.
Dealloc_T & get_nonconst_dealloc(const ArrayRCP< T > &p)
Return a non-const reference to the underlying deallocator object.
ArrayRCP< T >::difference_type operator-(const ArrayRCP< T > &p1, const ArrayRCP< T > &p2)
Return the difference of two ArrayRCP objects.
bool nonnull(const ArrayRCP< T > &p)
Returns true if p.get()!=NULL.
T * pointer
Type of a (raw) (nonconstant) pointer to an array element.
iterator end() const
Return an iterator to past the end of the array of data.
RCP< std::vector< T > > get_std_vector(const ArrayRCP< T > &ptr)
Get an std::vector<T> object out of an ArrayRCP<T> object that was created using the arcp() function ...
bool operator>(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using >.
ArrayRCP< T2 > arcp_implicit_cast(const ArrayRCP< T1 > &p1)
Implicit case the underlying ArrayRCP type from T1* to T2*.
ArrayRCP< T > arcpWithEmbeddedObjPreDestroy(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
T * const_pointer
Type of a (raw) (constant) pointer to an array element.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
const T1 * get_optional_extra_data(const ArrayRCP< T2 > &p, const std::string &name)
Get a pointer to const extra data (if it exists) associated with a ArrayRCP object.
ArrayRCP< const T > arcp(const RCP< const std::vector< T > > &v)
Wrap a const std::vector<T> object as an ArrayRCP<const T> object.
ArrayRCP< T > arcp(const RCP< std::vector< T > > &v)
Wrap an std::vector<T> object as an ArrayRCP<T> object.
ArrayRCP< T > & operator-=(size_type offset)
Pointer integer increment (i.e. ptr-=offset).
bool operator<=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using <=.
bool operator!=(const ArrayRCP< T > &p, ENull)
Returns true if p.get()!=NULL.
int weak_count() const
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-co...
const Embedded & getEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(),...
int total_count() const
Total count (strong_count() + weak_count()).
Nonowning array view.
Base traits class for getting a properly initialized null pointer.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Handle class that manages the RCPNode's reference counting.
Smart reference counting pointer class for automatic garbage collection.
ERCPStrength
Used to specify if the pointer is weak or strong.
ERCPNodeLookup
Used to determine if RCPNode lookup is performed or not.
EPrePostDestruction
Used to specify a pre or post destruction of extra data.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...