Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
Teuchos_ArrayRCPDecl.hpp
Go to the documentation of this file.
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"
50 
51 
52 namespace Teuchos {
53 
126 template<class T>
127 class ArrayRCP {
128 public:
130 
131 
134 
136  typedef Ordinal size_type;
137 
139  typedef Ordinal difference_type;
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
166  typedef ArrayRCP<T> iterator;
170 #else
171  typedef T* iterator;
174  typedef const T* const_iterator;
175 #endif
176 
178 
180 
193  inline ArrayRCP( ENull null_arg = null );
194 
216  inline ArrayRCP( T* p, size_type lowerOffset, size_type size,
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 
513  inline ArrayRCP<T> persistingView( size_type lowerOffset, size_type size ) const;
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 
548  inline ArrayView<T> view( size_type lowerOffset, size_type size ) const;
549 
554  inline ArrayView<T> operator()( size_type lowerOffset, size_type size ) const;
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 
765  inline const ArrayRCP<T>& assert_in_range( size_type lowerOffset, size_type size ) const;
766 
776  inline const ArrayRCP<T>& assert_valid_ptr() const;
777 
779 
781 
783  inline TEUCHOS_DEPRECATED int count() const;
784 
786 
787 private:
789  T *ptr_;
793  size_type lowerOffset_;
795  size_type upperOffset_;
796 
797  inline void debug_assert_not_null () const {
798 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
799  assert_not_null();
800 #endif
801  }
802 
803  inline void
804  debug_assert_in_range (size_type lowerOffset_in,
805  size_type size_in) const
806  {
807  (void) lowerOffset_in;
808  (void) size_in;
809 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
810  assert_in_range (lowerOffset_in, size_in);
811 #endif
812  }
813 
814  inline void debug_assert_valid_ptr() const {
815 #ifdef TEUCHOS_DEBUG
816  assert_valid_ptr ();
817 #endif
818  }
819 
820 public:
821 
822 #ifndef DOXYGEN_COMPILE
823  // These constructors should be private but I have not had good luck making
824  // this portable (i.e. using friendship etc.) in the past
825  // This is a very bad breach of encapsulation that is needed since MS VC++
826  // 5.0 will not allow me to declare template functions as friends.
827  ArrayRCP( T* p, size_type lowerOffset, size_type size,
828  const RCPNodeHandle& node );
829  T* access_private_ptr() const;
830  RCPNodeHandle& nonconst_access_private_node();
831  const RCPNodeHandle& access_private_node() const;
832 #endif
833 
834 };
835 
836 
844 template<class T>
845 class ArrayRCP<const T> {
846 public:
848  typedef Ordinal size_type;
849  typedef Ordinal difference_type;
850  typedef std::random_access_iterator_tag iterator_category;
851  typedef const T* iterator_type;
852  typedef const T value_type;
853  typedef const T& reference;
854  typedef const T& const_reference;
855  typedef const T* pointer;
856  typedef const T* const_pointer;
857  typedef const T element_type;
858 
859 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
860  typedef ArrayRCP<const T> iterator;
862 #else
863  typedef const T* iterator;
864  typedef const T* const_iterator;
865 #endif
866 
867  inline ArrayRCP (ENull null_arg = null);
868  inline ArrayRCP (const T* p, size_type lowerOffset,
869  size_type size, bool has_ownership,
870  const ERCPNodeLookup rcpNodeLookup = RCP_ENABLE_NODE_LOOKUP);
871  template<class Dealloc_T>
872  inline ArrayRCP (const T* p, size_type lowerOffset, size_type size,
873  Dealloc_T dealloc, bool has_ownership);
874  inline explicit ArrayRCP (size_type size, const T& val = T ());
875  inline ArrayRCP (const ArrayRCP<const T>& r_ptr);
876  inline ~ArrayRCP();
877 
878  inline ArrayRCP<const T>& operator= (const ArrayRCP<const T>& r_ptr);
879  inline bool is_null() const;
880  inline const T* operator->() const;
881  inline const T& operator*() const;
882  inline const T* get() const;
883  inline const T* getRawPtr() const;
884  inline const T& operator[] (size_type offset) const;
885 
886  inline ArrayRCP<const T>& operator++ ();
887  inline ArrayRCP<const T> operator++ (int);
888  inline ArrayRCP<const T>& operator-- ();
889  inline ArrayRCP<const T> operator-- (int);
890  inline ArrayRCP<const T>& operator+= (size_type offset);
891  inline ArrayRCP<const T>& operator-= (size_type offset);
892  inline ArrayRCP<const T> operator+ (size_type offset) const;
893  inline ArrayRCP<const T> operator- (size_type offset) const;
894 
895  inline iterator begin() const;
896  inline iterator end() const;
897 
903  inline ArrayRCP<const T> getConst () const;
904  inline ArrayRCP<const T> persistingView (size_type lowerOffset, size_type size) const;
905 
906  inline size_type lowerOffset() const;
907  inline size_type upperOffset() const;
908  inline size_type size() const;
909 
910  inline ArrayView<const T> view (size_type lowerOffset, size_type size) const;
911  inline ArrayView<const T> operator() (size_type lowerOffset, size_type size) const;
912  inline ArrayView<const T> operator() () const;
913 
914  inline void resize (const size_type n, const T& val = T ());
915  inline void clear ();
916 
917  inline ERCPStrength strength() const;
918  inline bool is_valid_ptr() const;
919  inline int strong_count() const;
920  inline int weak_count() const;
921  inline int total_count() const;
922  inline void set_has_ownership();
923  inline bool has_ownership() const;
924  inline const T* release();
925  inline ArrayRCP<const T> create_weak() const;
926  inline ArrayRCP<const T> create_strong() const;
927 
928  template<class T2>
929  inline bool shares_resource (const ArrayRCP<T2>& r_ptr) const;
930 
931  inline const ArrayRCP<const T>& assert_not_null () const;
932  inline const ArrayRCP<const T>& assert_in_range (size_type lowerOffset, size_type size) const;
933  inline const ArrayRCP<const T>& assert_valid_ptr() const;
934 
935  inline TEUCHOS_DEPRECATED int count() const;
936 
937 private:
938  const T* ptr_; // NULL if this pointer is null
939  RCPNodeHandle node_; // NULL if this pointer is null
940  size_type lowerOffset_; // 0 if this pointer is null
941  size_type upperOffset_; // -1 if this pointer is null
942 
943  inline void debug_assert_not_null() const {
944 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
945  assert_not_null ();
946 #endif
947  }
948 
949  inline void
950  debug_assert_in_range (size_type lowerOffset_in,
951  size_type size_in) const
952  {
953  (void) lowerOffset_in; (void) size_in;
954 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
955  assert_in_range (lowerOffset_in, size_in);
956 #endif
957  }
958 
959  inline void debug_assert_valid_ptr() const {
960 #ifdef TEUCHOS_DEBUG
961  assert_valid_ptr ();
962 #endif
963  }
964 
965 public:
966 
967 #ifndef DOXYGEN_COMPILE
968  // These constructors should be private but I have not had good luck making
969  // this portable (i.e. using friendship etc.) in the past
970  // This is a very bad breach of encapsulation that is needed since MS VC++
971  // 5.0 will not allow me to declare template functions as friends.
972  ArrayRCP (const T* p, size_type lowerOffset,
973  size_type size, const RCPNodeHandle& node);
974  const T* access_private_ptr() const;
975  RCPNodeHandle& nonconst_access_private_node();
976  const RCPNodeHandle& access_private_node() const;
977 #endif
978 };
979 
980 
989 template<>
990 class ArrayRCP<void> {
991 public:
993  typedef Ordinal size_type;
994  typedef Ordinal difference_type;
995  typedef std::random_access_iterator_tag iterator_category;
996  typedef void* iterator_type;
997  typedef void value_type;
999  // typedef T& reference; // these are not valid
1001  // typedef const T& const_reference; // these are not valid
1002  typedef void* pointer;
1003  typedef void* const_pointer;
1004  typedef void element_type;
1005 
1007  inline ArrayRCP ();
1008 };
1009 
1014 template<>
1015 class ArrayRCP<const void> {
1016 public:
1018  typedef Ordinal size_type;
1019  typedef Ordinal difference_type;
1020  typedef std::random_access_iterator_tag iterator_category;
1021  typedef const void* iterator_type;
1022  typedef const void value_type;
1024  // typedef T& reference; // these are not valid
1026  // typedef const T& const_reference; // these are not valid
1027  typedef const void* pointer;
1028  typedef const void* const_pointer;
1029  typedef const void element_type;
1030 
1032  inline ArrayRCP ();
1033 };
1034 
1035 // 2008/09/22: rabartl: NOTE: I removed the TypeNameTraits<ArrayRCP<T> >
1036 // specialization since I want to be able to print the type name of an
1037 // ArrayRCP that does not have the type T fully defined!
1038 
1039 
1044 template<typename T>
1046 public:
1047  static ArrayRCP<T> getNull() { return null; }
1048 };
1049 
1050 
1056 template<class T>
1058  T* p,
1060  typename ArrayRCP<T>::size_type size,
1061  bool owns_mem = true
1062  );
1063 
1064 
1070 template<class T, class Dealloc_T>
1072  T* p,
1073  typename ArrayRCP<T>::size_type lowerOffset,
1074  typename ArrayRCP<T>::size_type size,
1075  Dealloc_T dealloc, bool owns_mem
1076  );
1077 
1078 
1089 template<class T>
1090 ArrayRCP<T> arcp( typename ArrayRCP<T>::size_type size );
1091 
1092 
1106 template<class T>
1108 
1109 
1114 template<class T>
1116 
1117 
1128 template<class T, class Embedded>
1131  T* p,
1132  typename ArrayRCP<T>::size_type lowerOffset,
1133  typename ArrayRCP<T>::size_type size,
1134  const Embedded &embedded,
1135  bool owns_mem = true
1136  );
1137 
1138 
1149 template<class T, class Embedded>
1152  T* p,
1153  typename ArrayRCP<T>::size_type lowerOffset,
1154  typename ArrayRCP<T>::size_type size,
1155  const Embedded &embedded,
1156  bool owns_mem = true
1157  );
1158 
1159 
1171 template<class T, class Embedded>
1174  T* p,
1175  typename ArrayRCP<T>::size_type lowerOffset,
1176  typename ArrayRCP<T>::size_type size,
1177  const Embedded &embedded,
1178  bool owns_mem = true
1179  );
1180 
1181 
1187 template<class T>
1188 ArrayRCP<T> arcp( const RCP<std::vector<T> > &v );
1189 
1190 
1196 template<class T>
1197 ArrayRCP<const T> arcp( const RCP<const std::vector<T> > &v );
1198 
1199 
1208 template<class T>
1210 
1211 
1218 template<class T>
1220 
1221 
1228 template<class T>
1230 
1231 
1236 template<class T>
1237 bool is_null( const ArrayRCP<T> &p );
1238 
1239 
1244 template<class T>
1245 bool nonnull( const ArrayRCP<T> &p );
1246 
1247 
1252 template<class T>
1253 bool operator==( const ArrayRCP<T> &p, ENull );
1254 
1255 
1260 template<class T>
1261 bool operator!=( const ArrayRCP<T> &p, ENull );
1262 
1263 
1268 template<class T1, class T2>
1269 bool operator==( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1270 
1271 
1276 template<class T1, class T2>
1277 bool operator!=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1278 
1279 
1284 template<class T1, class T2>
1285 bool operator<( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1286 
1287 
1292 template<class T1, class T2>
1293 bool operator<=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1294 
1295 
1300 template<class T1, class T2>
1301 bool operator>( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1302 
1303 
1308 template<class T1, class T2>
1309 bool operator>=( const ArrayRCP<T1> &p1, const ArrayRCP<T2> &p2 );
1310 
1311 
1316 template<class T>
1318 operator-( const ArrayRCP<T> &p1, const ArrayRCP<T> &p2 );
1319 
1320 
1331 template<class T2, class T1>
1332 inline
1334 
1335 
1347 template<class T2, class T1>
1349 
1350 
1367 template<class T2, class T1>
1368 ArrayRCP<T2> arcp_reinterpret_cast_nonpod(const ArrayRCP<T1>& p1, const T2& val=T2());
1369 
1370 
1396 template<class T2, class T1>
1397 inline
1399 
1400 
1459 template<class T1, class T2>
1460 void set_extra_data(
1461  const T1 &extra_data, const std::string& name,
1462  const Ptr<ArrayRCP<T2> > &p, EPrePostDestruction destroy_when = POST_DESTROY,
1463  bool force_unique = true );
1464 
1465 
1485 template<class T1, class T2>
1486 T1& get_extra_data( ArrayRCP<T2>& p, const std::string& name );
1487 
1488 
1514 template<class T1, class T2>
1515 const T1& get_extra_data( const ArrayRCP<T2>& p, const std::string& name );
1516 
1517 
1542 template<class T1, class T2>
1543 T1* get_optional_extra_data( ArrayRCP<T2>& p, const std::string& name );
1544 
1545 
1575 template<class T1, class T2>
1576 const T1* get_optional_extra_data( const ArrayRCP<T2>& p, const std::string& name );
1577 
1578 
1589 template<class Dealloc_T, class T>
1590 Dealloc_T& get_nonconst_dealloc( const ArrayRCP<T>& p );
1591 
1592 
1610 template<class Dealloc_T, class T>
1611 const Dealloc_T& get_dealloc( const ArrayRCP<T>& p );
1612 
1613 
1628 template<class Dealloc_T, class T>
1629 const Dealloc_T* get_optional_dealloc( const ArrayRCP<T>& p );
1630 
1631 
1653 template<class Dealloc_T, class T>
1654 Dealloc_T* get_optional_nonconst_dealloc( const ArrayRCP<T>& p );
1655 
1656 
1663 template<class TOrig, class Embedded, class T>
1664 const Embedded& getEmbeddedObj( const ArrayRCP<T>& p );
1665 
1666 
1673 template<class TOrig, class Embedded, class T>
1674 Embedded& getNonconstEmbeddedObj( const ArrayRCP<T>& p );
1675 
1676 
1684 template<class T>
1685 std::ostream& operator<<( std::ostream& out, const ArrayRCP<T>& p );
1686 
1687 
1688 } // end namespace Teuchos
1689 
1690 
1691 #endif // TEUCHOS_ARRAY_RCP_DECL_HPP
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...
bool operator>(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
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.
const T * const_iterator
Constant iterator type used if bounds checking is disabled.
std::random_access_iterator_tag iterator_category
Category of ArrayRCP&#39;s iterator type.
size_type lowerOffset_
Lower offset to the data; 0 if this array is null.
TEUCHOS_DEPRECATED int count() const
Returns strong_count() [deprecated].
ERCPStrength
Used to specify if the pointer is weak or strong.
const Embedded & getEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(), arcpWithEmbeddedObjPostDestory(), or arcpWithEmbeddedObj().
ArrayRCP< T > create_weak() const
Create a new weak reference from another (strong) reference.
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 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::random_access_iterator_tag iterator_category
Dealloc_T & get_nonconst_dealloc(const ArrayRCP< T > &p)
Return a non-const reference to the underlying deallocator object.
ArrayRCP(ENull null_arg=null)
Default constructor; initialize to an empty array.
ArrayRCP< T > persistingView(size_type lowerOffset, size_type size) const
Return a persisting view of a contiguous range of elements.
const Dealloc_T & get_dealloc(const ArrayRCP< T > &p)
Return a const reference to the underlying deallocator object.
T1 & get_extra_data(ArrayRCP< T2 > &p, const std::string &name)
Get a non-const reference to extra data associated with a ArrayRCP object.
Partial specialization of ArrayRCP for const T.
bool operator!=(const ArrayRCP< T > &p, ENull)
Returns true if p.get()!=NULL.
Ordinal difference_type
Type representing the difference between two size_type values.
ArrayRCP< T > & operator++()
Prefix increment of pointer (i.e. ++ptr).
ArrayRCP< T > arcpClone(const ArrayView< const T > &v)
Allocate a new array by cloning data from an input array view.
ArrayRCP< T > & operator+=(size_type offset)
Pointer integer increment (i.e. ptr+=offset).
int weak_count() const
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-co...
ArrayRCP< T > & operator-=(size_type offset)
Pointer integer increment (i.e. ptr-=offset).
bool operator>=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Dealloc_T * get_optional_nonconst_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying const deallocator object if it exists.
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
size_type upperOffset() const
Return the upper offset to valid data.
ArrayRCP< T > & operator--()
Prefix decrement of pointer (i.e. –ptr).
T * release()
Release the ownership of the underlying array.
ERCPNodeLookup
Used to determine if RCPNode lookup is performed or not.
ArrayRCP< T > arcp(const RCP< Array< T > > &v)
Wrap an RCP<Array<T> > object as an ArrayRCP<T> object.
ArrayRCP< const T > getConst() const
Return object for only const access to data.
void clear()
Resize to zero.
size_type size() const
The total number of entries in the array.
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof.
~ArrayRCP()
Destructor, that decrements the reference count.
ERCPStrength strength() const
Strength of the pointer.
void debug_assert_valid_ptr() const
RCPNodeHandle node_
Reference-counting machinery.
bool shares_resource(const ArrayRCP< T2 > &r_ptr) const
Returns true if the smart pointers share the same underlying reference-counted object.
void debug_assert_not_null() const
bool is_valid_ptr() const
Return whether the underlying object pointer is still valid.
const ArrayRCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
T element_type
Type of each array element.
T * operator->() const
Pointer (->) access to members of underlying object for current position.
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*.
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.
void resize(const size_type n, const T &val=T())
Resize and append new elements if necessary.
ArrayRCP< T > arcpFromArrayView(const ArrayView< T > &av)
Get an ArrayRCP object out of an ArrayView object.
T * const_pointer
Type of a (raw) (constant) pointer to an array element.
Teuchos_Ordinal Ordinal
Integer index type used throughout ArrayRCP.
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
ArrayRCP< T > create_strong() const
Create a new strong RCP object from another (weak) RCP object.
ArrayRCP< T2 > arcp_implicit_cast(const ArrayRCP< T1 > &p1)
Implicit case the underlying ArrayRCP type from T1* to T2*.
T value_type
Type of each array element.
std::random_access_iterator_tag iterator_category
ArrayRCP< T > operator+(size_type offset) const
Pointer integer increment (i.e. ptr+offset).
void deepCopy(const ArrayView< const T > &av)
Deep copy the elements from one ArrayView object into this object.
size_type lowerOffset() const
Return the lower offset to valid data.
const Dealloc_T * get_optional_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying non-const deallocator object if it exists.
int total_count() const
Total count (strong_count() + weak_count()).
bool operator==(const ArrayRCP< T > &p, ENull)
Returns true if p.get()==NULL.
ArrayRCP< T > arcpCloneNode(const ArrayRCP< T > &a)
Allocate a new ArrayRCP object with a new RCPNode with memory pointing to the initial node...
T & operator*() const
Dereference the underlying object for the current pointer position.
Base traits class for getting a properly initialized null pointer.
T * ptr_
Raw pointer to the array; NULL if this array is null.
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.
T * iterator_type
Type of an ArrayRCP&#39;s iterator.
const T & const_reference
Type of a (constant) reference to an array element.
T * pointer
Type of a (raw) (nonconstant) pointer to an array element.
Nonowning array view.
void set_has_ownership()
Give this and other ArrayRCP<> objects ownership of the underlying referenced array to delete it...
EPrePostDestruction
Used to specify a pre or post destruction of extra data.
Handle class that manages the RCPNode&#39;s reference counting.
void debug_assert_in_range(size_type lowerOffset_in, size_type size_in) const
ArrayView< T > operator()() const
Return a nonpersisting view of *this.
std::random_access_iterator_tag iterator_category
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
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() above to ...
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.
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*.
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 decrement (i.e. ptr-offset).
Smart reference counting pointer class for automatic garbage collection.
T & operator[](size_type offset) const
Random object access.
T * iterator
Nonconstant iterator type used if bounds checking is disabled.
iterator end() const
Return an iterator to past the end of the array of data.
Partial specialization of ArrayView for const T.
size_type upperOffset_
Upper offset to the data; -1 if this array is null.
T & reference
Type of a (nonconstant) reference to an array element.
bool is_null() const
True if the underlying pointer is null, else false.
void debug_assert_in_range(size_type lowerOffset_in, size_type size_in) const
Reference-counted pointer class and non-member templated function implementations.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
iterator begin() const
Return an iterator to beginning of the array of data.
bool has_ownership() const
Returns true if this has ownership of object pointed to by this->get() in order to deallocate it...
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
bool nonnull(const ArrayRCP< T > &p)
Returns true if p.get()!=NULL.
Embedded & getNonconstEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(), arcpWithEmbeddedObjPostDestory(), or arcpWithEmbeddedObj().
void assign(size_type n, const T &val)
Resize and assign n elements of val.
Reference-counted smart pointer for managing arrays.
ArrayView< T > view(size_type lowerOffset, size_type size) const
Return a nonpersisting view of a contiguous range of elements.