10 #ifndef TEUCHOS_ARRAY_RCP_HPP
11 #define TEUCHOS_ARRAY_RCP_HPP
27 template<
class T>
inline
36 template<
class T,
class Dealloc_T>
39 T* p, Dealloc_T dealloc,
bool has_ownership_in
46 template<
class T2,
class T1>
74 for (itr_t itr = arcp2.
begin(); itr != arcp2.
end(); ++itr) {
85 template<
class T>
inline
87 : ptr_(NULL), lowerOffset_(0), upperOffset_(-1)
90 template<
class T>
inline
92 : ptr_(NULL), lowerOffset_(0), upperOffset_(-1)
96 template<
class T>
inline
98 : ptr_(0), lowerOffset_(0), upperOffset_(-1)
101 std::fill_n(
begin(), n, val);
104 template<
class T>
inline
106 : ptr_(0), lowerOffset_(0), upperOffset_(-1)
115 template<
class T>
inline
121 #ifndef TEUCHOS_DEBUG
124 lowerOffset_(lowerOffset_in),
125 upperOffset_(size_in + lowerOffset_in - 1)
133 if (existing_RCPNode) {
148 #else // NOT TEUCHOS_DEBUG
149 (void) rcpNodeLookup;
150 #endif // TEUCHOS_DEBUG
153 template<
class T>
inline
158 #ifndef TEUCHOS_DEBUG
161 lowerOffset_(lowerOffset_in),
162 upperOffset_(size_in + lowerOffset_in - 1)
170 if (existing_RCPNode) {
185 #else // NOT TEUCHOS_DEBUG
186 (void) rcpNodeLookup;
187 #endif // TEUCHOS_DEBUG
192 template<
class Dealloc_T>
196 Dealloc_T dealloc,
bool has_ownership_in
199 #ifndef TEUCHOS_DEBUG
202 lowerOffset_(lowerOffset_in),
203 upperOffset_(size_in + lowerOffset_in - 1)
214 #endif // TEUCHOS_DEBUG
218 template<
class Dealloc_T>
222 Dealloc_T dealloc,
bool has_ownership_in
225 #ifndef TEUCHOS_DEBUG
228 lowerOffset_(lowerOffset_in),
229 upperOffset_(size_in + lowerOffset_in - 1)
240 #endif // TEUCHOS_DEBUG
244 template<
class T>
inline
248 lowerOffset_(r_ptr.lowerOffset_),
249 upperOffset_(r_ptr.upperOffset_)
252 template<
class T>
inline
256 lowerOffset_(r_ptr.lowerOffset_),
257 upperOffset_(r_ptr.upperOffset_)
261 template<
class T>
inline
264 template<
class T>
inline
268 template<
class T>
inline
273 node_ = r_ptr.access_private_node();
282 template<
class T>
inline
286 if (
this == &r_ptr) {
289 node_ = r_ptr.access_private_node ();
302 template<
class T>
inline
307 template<
class T>
inline
313 template<
class T>
inline
316 debug_assert_valid_ptr();
317 debug_assert_in_range(0,1);
321 template<
class T>
inline
330 template<
class T>
inline
333 debug_assert_valid_ptr();
334 debug_assert_in_range(0,1);
338 template<
class T>
inline
347 template<
class T>
inline
351 debug_assert_valid_ptr();
352 debug_assert_in_range(0,1);
357 template<
class T>
inline
368 template<
class T>
inline
373 template<
class T>
inline
379 template<
class T>
inline
382 debug_assert_valid_ptr();
383 debug_assert_in_range(offset,1);
387 template<
class T>
inline
399 template<
class T>
inline
402 debug_assert_valid_ptr();
409 template<
class T>
inline
420 template<
class T>
inline
423 debug_assert_valid_ptr();
429 template<
class T>
inline
439 template<
class T>
inline
442 debug_assert_valid_ptr();
449 template<
class T>
inline
460 template<
class T>
inline
463 debug_assert_valid_ptr();
469 template<
class T>
inline
479 template<
class T>
inline
482 debug_assert_valid_ptr();
484 lowerOffset_ -= offset;
485 upperOffset_ -= offset;
489 template<
class T>
inline
500 template<
class T>
inline
503 debug_assert_valid_ptr();
505 lowerOffset_ += offset;
506 upperOffset_ += offset;
510 template<
class T>
inline
521 template<
class T>
inline
529 template<
class T>
inline
538 template<
class T>
inline
546 template<
class T>
inline
558 template<
class T>
inline
561 debug_assert_valid_ptr();
562 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
569 template<
class T>
inline
573 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
581 template<
class T>
inline
584 debug_assert_valid_ptr();
585 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
586 return *
this + (upperOffset_ + 1);
588 return ptr_ + (upperOffset_ + 1);
592 template<
class T>
inline
596 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
607 template<
class T>
inline
611 debug_assert_valid_ptr();
612 const T *cptr = ptr_;
618 template<
class T>
inline
625 template<
class T>
inline
632 debug_assert_valid_ptr();
633 debug_assert_in_range(lowerOffset_in, size_in);
635 ptr.
ptr_ = ptr.
ptr_ + lowerOffset_in;
641 template<
class T>
inline
651 ptr.
ptr_ = ptr.
ptr_ + lowerOffset_in;
661 template<
class T>
inline
665 debug_assert_valid_ptr();
669 template<
class T>
inline
678 template<
class T>
inline
682 debug_assert_valid_ptr();
686 template<
class T>
inline
695 template<
class T>
inline
699 debug_assert_valid_ptr();
700 return upperOffset_ - lowerOffset_ + 1;
703 template<
class T>
inline
715 template<
class T>
inline
721 debug_assert_valid_ptr();
722 debug_assert_in_range(lowerOffset_in,size_in);
723 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
724 return ArrayView<T>(persistingView(lowerOffset_in, size_in).create_weak());
726 return arrayView(ptr_ + lowerOffset_in, size_in);
731 template<
class T>
inline
740 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
743 return arrayView(
ptr_ + lowerOffset_in, size_in);
749 template<
class T>
inline
752 return view(lowerOffset_in, size_in);
755 template<
class T>
inline
759 return view (lowerOffset_in, size_in);
763 template<
class T>
inline
767 return view(lowerOffset_, size());
772 template<
class T>
inline
785 template<
class T>
inline
806 template<
class T>
inline
809 std::fill_n (this->begin (), n, val);
817 const size_type new_n = std::distance (first, last);
818 if (new_n != size ()) {
819 *
this = arcp<T> (new_n);
821 std::copy (first, last, begin ());
825 template<
class T>
inline
839 const size_type small_n = std::min(n, orig_n);
848 template<
class T>
inline
865 const size_type small_n = std::min (n, orig_n);
866 for (
size_type i = 0; i < small_n; ++i) {
867 nonconstThis[i] = tmp[i];
870 nonconstThis[i] = val;
878 template<
class T>
inline
883 template<
class T>
inline
892 template<
class T>
inline
895 if (av.
size() == 0) {
906 template<
class T>
inline
908 return node_.strength();
911 template<
class T>
inline
917 template<
class T>
inline
921 return node_.is_valid_ptr();
925 template<
class T>
inline
934 template<
class T>
inline
937 return node_.strong_count();
940 template<
class T>
inline
947 template<
class T>
inline
950 return node_.weak_count();
953 template<
class T>
inline
960 template<
class T>
inline
963 return node_.total_count();
966 template<
class T>
inline
973 template<
class T>
inline
976 node_.has_ownership(
true);
979 template<
class T>
inline
986 template<
class T>
inline
989 return node_.has_ownership();
992 template<
class T>
inline
999 template<
class T>
inline
1002 debug_assert_valid_ptr();
1003 node_.has_ownership(
false);
1007 template<
class T>
inline
1016 template<
class T>
inline
1018 debug_assert_valid_ptr ();
1019 return ArrayRCP<T> (ptr_, lowerOffset_, size (), node_.create_weak ());
1022 template<
class T>
inline
1029 template<
class T>
inline
1031 debug_assert_valid_ptr ();
1032 return ArrayRCP<T> (ptr_, lowerOffset_, size (), node_.create_strong ());
1035 template<
class T>
inline
1047 return node_.same_node (r_ptr.access_private_node ());
1068 template<
class T>
inline
1073 throw_null_ptr_error(
typeName(*
this));
1077 template<
class T>
inline
1082 throw_null_ptr_error (
typeName (*
this));
1088 template<
class T>
inline
1092 node_.assert_valid_ptr (*
this);
1097 template<
class T>
inline
1107 template<
class T>
inline
1114 (lowerOffset_ <= lowerOffset_in && lowerOffset_in+size_in-1 <= upperOffset_)
1119 typeName(*
this)<<
"::assert_in_range:"
1120 " Error, [lowerOffset,lowerOffset+size-1] = ["
1121 <<lowerOffset_in<<
","<<(lowerOffset_in+size_in-1)<<
"] does not lie in the"
1122 " range ["<<lowerOffset_<<
","<<upperOffset_<<
"]!"
1127 template<
class T>
inline
1140 typeName (*
this) <<
"::assert_in_range:"
1141 " Error, [lowerOffset,lowerOffset+size-1] = ["
1142 <<lowerOffset_in<<
","<<(lowerOffset_in+size_in-1)<<
"] does not lie in the"
1152 template<
class T>
inline
1159 lowerOffset_(lowerOffset_in),
1160 upperOffset_(size_in + lowerOffset_in - 1)
1163 template<
class T>
inline
1170 lowerOffset_(lowerOffset_in),
1171 upperOffset_(size_in + lowerOffset_in - 1)
1175 template<
class T>
inline
1181 template<
class T>
inline
1182 const T* ArrayRCP<const T>::access_private_ptr ()
const
1188 template<
class T>
inline
1189 RCPNodeHandle& ArrayRCP<T>::nonconst_access_private_node()
1194 template<
class T>
inline
1195 RCPNodeHandle& ArrayRCP<const T>::nonconst_access_private_node()
1201 template<
class T>
inline
1202 const RCPNodeHandle& ArrayRCP<T>::access_private_node()
const
1207 template<
class T>
inline
1208 const RCPNodeHandle& ArrayRCP<const T>::access_private_node()
const
1237 namespace Utilities {
1238 template<
class T1,
class T2>
1243 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
1246 "Error, these iterators are *not* pointing to the same valid memory!"
1254 template<
class T>
inline
1257 T* p,
typename ArrayRCP<T>::size_type lowerOffset
1258 ,
typename ArrayRCP<T>::size_type size_in
1262 return ArrayRCP<T>(p, lowerOffset, size_in, owns_mem);
1266 template<
class T,
class Dealloc_T>
1270 T* p,
typename ArrayRCP<T>::size_type lowerOffset
1271 ,
typename ArrayRCP<T>::size_type size_in
1272 ,Dealloc_T dealloc,
bool owns_mem
1275 return ArrayRCP<T>(p, lowerOffset, size_in, dealloc, owns_mem);
1279 template<
class T>
inline
1281 Teuchos::arcp(
typename ArrayRCP<T>::size_type
size )
1283 #ifdef TEUCHOS_DEBUG
1289 return ArrayRCP<T>(
new T[
size], 0,
size,
true);
1293 template<
class T>
inline
1295 Teuchos::arcpCloneNode(
const ArrayRCP<T> &a)
1305 template<
class T>
inline
1307 Teuchos::arcpClone(
const ArrayView<const T> &v )
1309 const ArrayRCP<T> new_arcp = arcp<T>(v.size());
1310 std::copy( v.begin(), v.end(), new_arcp.begin() );
1315 template<
class T,
class Embedded>
1317 Teuchos::arcpWithEmbeddedObjPreDestroy(
1319 typename ArrayRCP<T>::size_type lowerOffset,
1320 typename ArrayRCP<T>::size_type size,
1321 const Embedded &embedded,
1326 p, lowerOffset, size,
1327 embeddedObjDeallocArrayDelete<T>(embedded,
PRE_DESTROY),
1333 template<
class T,
class Embedded>
1335 Teuchos::arcpWithEmbeddedObjPostDestroy(
1337 typename ArrayRCP<T>::size_type lowerOffset,
1338 typename ArrayRCP<T>::size_type size,
1339 const Embedded &embedded,
1344 p, lowerOffset, size,
1345 embeddedObjDeallocArrayDelete<T>(embedded,
POST_DESTROY),
1351 template<
class T,
class Embedded>
1353 Teuchos::arcpWithEmbeddedObj(
1355 typename ArrayRCP<T>::size_type lowerOffset,
1356 typename ArrayRCP<T>::size_type size,
1357 const Embedded &embedded,
1361 return arcpWithEmbeddedObjPostDestroy<T,Embedded>(
1362 p, lowerOffset,
size, embedded, owns_mem );
1366 template<
class T>
inline
1368 Teuchos::arcp(
const RCP<std::vector<T> > &v )
1370 if (
is_null(v) || !v->size() )
1372 return arcpWithEmbeddedObjPostDestroy<T,RCP<std::vector<T> > >(
1373 &(*v)[0], 0, v->size(),
1379 template<
class T>
inline
1381 Teuchos::arcp(
const RCP<
const std::vector<T> > &v )
1383 if (
is_null(v) || !v->size() )
1385 return arcpWithEmbeddedObjPostDestroy<const T,RCP<const std::vector<T> > >(
1386 &(*v)[0], 0, v->size(),
1392 template<
class T>
inline
1394 Teuchos::arcpFromArrayView(
const ArrayView<T> &av)
1396 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
1397 return av.access_private_arcp();
1399 return arcp(av.getRawPtr(), 0, av.size(),
false);
1404 template<
class T>
inline
1406 Teuchos::get_std_vector(
const ArrayRCP<T> &
ptr )
1408 return getEmbeddedObj<T, RCP<std::vector<T> > >(
ptr);
1412 template<
class T>
inline
1414 Teuchos::get_std_vector(
const ArrayRCP<const T> &
ptr )
1416 return getEmbeddedObj<const T, RCP<const std::vector<T> > >(
ptr);
1420 template<
class T>
inline
1427 template<
class T>
inline
1430 return !p.is_null();
1434 template<
class T>
inline
1441 template<
class T>
inline
1444 return !p.is_null();
1448 template<
class T1,
class T2>
1452 return p1.access_private_ptr() == p2.access_private_ptr();
1456 template<
class T1,
class T2>
1460 return p1.access_private_ptr() != p2.access_private_ptr();
1464 template<
class T1,
class T2>
1466 bool Teuchos::operator<( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 )
1468 return p1.access_private_ptr() < p2.access_private_ptr();
1472 template<
class T1,
class T2>
1474 bool Teuchos::operator<=( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 )
1477 return p1.access_private_ptr() <= p2.access_private_ptr();
1481 template<
class T1,
class T2>
1486 return p1.access_private_ptr() > p2.access_private_ptr();
1490 template<
class T1,
class T2>
1495 return p1.access_private_ptr() >= p2.access_private_ptr();
1504 return p1.access_private_ptr() - p2.access_private_ptr();
1508 template<
class T2,
class T1>
1511 Teuchos::arcp_reinterpret_cast(
const ArrayRCP<T1>& p1)
1514 const int sizeOfT1 =
sizeof(T1);
1515 const int sizeOfT2 =
sizeof(T2);
1516 size_type lowerOffset2 = (p1.lowerOffset()*sizeOfT1) / sizeOfT2;
1517 size_type upperOffset2 = ((p1.upperOffset()+1)*sizeOfT1) / sizeOfT2 - 1;
1518 T2 *ptr2 =
reinterpret_cast<T2*
>(p1.get());
1519 return ArrayRCP<T2>(
1520 ptr2, lowerOffset2, upperOffset2 - lowerOffset2 + 1,
1521 p1.access_private_node()
1527 template<
class T2,
class T1>
1529 Teuchos::arcp_reinterpret_cast_nonpod(
const ArrayRCP<T1>& p1,
const T2& val)
1531 typedef typename ArrayRCP<T2>::iterator itr_t;
1533 for (itr_t itr = arcp2.begin(); itr != arcp2.end(); ++itr) {
1534 new (&*itr) T2(val);
1537 arcp2.getRawPtr(), 0, arcp2.size(),
1538 ArcpReinterpretCastEmbeddedObj<T2, T1>(p1),
1546 template<
class T2,
class T1>
1549 Teuchos::arcp_const_cast(
const ArrayRCP<T1>& p1)
1551 T2 *ptr2 =
const_cast<T2*
>(p1.get());
1552 return ArrayRCP<T2>(
1553 ptr2, p1.lowerOffset(), p1.size(),
1554 p1.access_private_node()
1560 template<
class T2,
class T1>
1563 Teuchos::arcp_implicit_cast(
const ArrayRCP<T1>& p1)
1565 T2 * raw_ptr2 = p1.
get();
1566 return ArrayRCP<T2>(
1567 raw_ptr2, p1.lowerOffset(), p1.size(),
1568 p1.access_private_node()
1574 template<
class T1,
class T2>
1576 void Teuchos::set_extra_data(
1577 const T1 &extra_data,
const std::string& name,
1582 p->assert_not_null();
1583 p->nonconst_access_private_node().set_extra_data( any(extra_data), name, destroy_when,
1588 template<
class T1,
class T2>
1590 T1& Teuchos::get_extra_data( ArrayRCP<T2>& p,
const std::string& name )
1592 p.assert_not_null();
1594 p.nonconst_access_private_node().get_extra_data(
1595 TypeNameTraits<T1>::name(), name
1601 template<
class T1,
class T2>
1603 const T1& Teuchos::get_extra_data(
const ArrayRCP<T2>& p,
const std::string& name )
1605 p.assert_not_null();
1607 p.access_private_node().get_extra_data(
1608 TypeNameTraits<T1>::name() ,name
1614 template<
class T1,
class T2>
1616 T1* Teuchos::get_optional_extra_data( ArrayRCP<T2>& p,
const std::string& name )
1618 p.assert_not_null();
1619 any *extra_data = p.nonconst_access_private_node().get_optional_extra_data(
1620 TypeNameTraits<T1>::name(), name);
1621 if( extra_data )
return &
any_cast<T1>(*extra_data);
1626 template<
class T1,
class T2>
1628 const T1* Teuchos::get_optional_extra_data(
const ArrayRCP<T2>& p,
const std::string& name )
1630 p.assert_not_null();
1631 any *extra_data = p.access_private_node().get_optional_extra_data(
1632 TypeNameTraits<T1>::name(), name);
1633 if( extra_data )
return &
any_cast<T1>(*extra_data);
1638 template<
class Dealloc_T,
class T>
1641 Teuchos::get_dealloc(
const ArrayRCP<T>& p )
1643 return get_nonconst_dealloc<Dealloc_T>(p);
1647 template<
class Dealloc_T,
class T>
1652 typedef RCPNodeTmpl<typename Dealloc_T::ptr_t,Dealloc_T> requested_type;
1654 RCPNodeTmpl<typename Dealloc_T::ptr_t,Dealloc_T>
1655 *dnode =
dynamic_cast<RCPNodeTmpl<typename Dealloc_T::ptr_t,Dealloc_T>*
>(
1656 p.access_private_node().node_ptr());
1658 dnode==NULL, NullReferenceError
1659 ,
"get_dealloc<" << TypeNameTraits<Dealloc_T>::name()
1660 <<
"," << TypeNameTraits<T>::name() <<
">(p): "
1661 <<
"Error, requested type \'" << TypeNameTraits<requested_type>::name()
1662 <<
"\' does not match actual type of the node \'"
1663 <<
typeName(*p.access_private_node().node_ptr()) <<
"!"
1665 return dnode->get_nonconst_dealloc();
1669 template<
class Dealloc_T,
class T>
1672 Teuchos::get_optional_dealloc(
const ArrayRCP<T>& p )
1674 return get_optional_dealloc<Dealloc_T>(p);
1678 template<
class Dealloc_T,
class T>
1684 typedef RCPNodeTmpl<typename Dealloc_T::ptr_t,Dealloc_T>
1686 RCPNT *dnode =
dynamic_cast<RCPNT*
>(p.access_private_node().node_ptr());
1688 return &dnode->get_nonconst_dealloc();
1693 template<
class TOrig,
class Embedded,
class T>
1694 const Embedded& Teuchos::getEmbeddedObj(
const ArrayRCP<T>& p )
1696 typedef EmbeddedObjDealloc<TOrig,Embedded,DeallocArrayDelete<TOrig> > Dealloc_t;
1697 return get_dealloc<Dealloc_t>(p).getObj();
1701 template<
class TOrig,
class Embedded,
class T>
1702 Embedded& Teuchos::getNonconstEmbeddedObj(
const ArrayRCP<T>& p )
1704 typedef EmbeddedObjDealloc<TOrig,Embedded,DeallocArrayDelete<TOrig> > Dealloc_t;
1705 return get_nonconst_dealloc<Dealloc_t>(p).getNonconstObj();
1710 std::ostream& Teuchos::operator<<( std::ostream& out, const ArrayRCP<T>& p )
1718 << TypeNameTraits<ArrayRCP<T> >::name() <<
"{"
1720 if (p.access_private_ptr () == NULL) {
1723 out << (
const void*) (p.access_private_ptr ());
1728 <<
",size="<<p.
size()
1729 <<
",node=" << p.access_private_node ()
1741 #endif // TEUCHOS_ARRAY_RCP_HPP
size_type lowerOffset_
Lower offset to the data; 0 if this array is null.
int weak_count() const
The weak count for this RCPNode, or 0 if the node is NULL.
ERCPStrength
Used to specify if the pointer is weak or strong.
ArrayRCP< T > create_weak() const
Create a new weak reference from another (strong) reference.
ArcpReinterpretCastEmbeddedObj & operator=(const ArcpReinterpretCastEmbeddedObj &arceo)
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::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
BigUInt< n > operator-(BigUInt< n > const &a, BigUInt< n > const &b)
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.
RCPNode * ArrayRCP_createNewDeallocRCPNodeRawPtr(T *p, Dealloc_T dealloc, bool has_ownership_in)
Partial specialization of ArrayRCP for const T.
Ordinal difference_type
Type representing the difference between two size_type values.
ArrayRCP< T > & operator++()
Prefix increment of pointer (i.e. ++ptr).
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...
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
ArcpReinterpretCastEmbeddedObj()
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
#define TEUCHOS_ASSERT_INEQUALITY(val1, comp, val2)
This macro is checks that an inequality between two numbers is satisified and if not then throws a go...
ValueType & any_cast(any &operand)
Used to extract the templated value held in Teuchos::any to a given value type.
ArrayRCP< T > & operator-=(size_type offset)
Pointer integer increment (i.e. ptr-=offset).
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
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 release()
Releaes the RCPNode pointer before the destructor is called.
ENull
Used to initialize a RCP object to NULL using an implicit conversion!
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.
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
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.
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.
bool operator!=(const Allocator< T > &a_t, const Allocator< U > &a_u)
Return ! (a_t == a_u) (see above).
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*.
void resize(const size_type n, const T &val=T())
Resize and append new elements if necessary.
Node class to keep track of address and the reference count for a reference-counted utility class and...
Deallocator class that uses delete [] to delete memory allocated uisng new []
Templated implementation class of RCPNode that has the responsibility for deleting the reference-coun...
bool operator>(BigUInt< n > const &a, BigUInt< n > const &b)
std::string concreteTypeName(const T &t)
Template function for returning the type name of the actual concrete name of a passed-in object...
bool operator>=(BigUInt< n > const &a, BigUInt< n > const &b)
void assert_valid_ptr(const RCPType &rcp_obj) const
ArrayRCP< T > create_strong() const
Create a new strong RCP object from another (weak) RCP object.
RCPNodeHandle create_strong() const
Return a strong handle.
ArrayRCP< T > operator+(size_type offset) const
Pointer integer increment (i.e. ptr+offset).
ERCPStrength strength() const
The strength of this handle.
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.
int total_count() const
Total count (strong_count() + weak_count()).
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Incompatiable iterators error exception class.
T & operator*() const
Dereference the underlying object for the current pointer position.
static RCPNode * getExistingRCPNode(T *p)
Return a raw pointer to an existing owning RCPNode given the address to the underlying object if it e...
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
T * ptr_
Raw pointer to the array; NULL if this array is null.
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's reference counting.
int strong_count() const
The strong count for this RCPNode, or 0 if the node is NULL.
void has_ownership(bool has_ownership_in)
void debug_assert_in_range(size_type lowerOffset_in, size_type size_in) const
ArrayView< T > operator()() const
Return a nonpersisting view of *this.
int total_count() const
The sum of the weak and string counts.
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
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*.
bool is_valid_ptr() const
Whether the underlying pointer is valid.
ArrayRCP< T > & operator=(const ArrayRCP< T > &r_ptr)
Assignment operator: Makes *this reference the input array.
void assert_shares_resource(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
ArcpReinterpretCastEmbeddedObj(const ArrayRCP< T1 > &arcp_pod)
ArrayRCP< T > operator-(size_type offset) const
Pointer integer decrement (i.e. ptr-offset).
Smart reference counting pointer class for automatic garbage collection.
bool same_node(const RCPNodeHandle &node2) const
Whether the RCPNode for which node2 is a handle is the same RCPNode as this object's RCPNode...
T & operator[](size_type offset) const
Random object access.
Deletes a (non-owning) RCPNode but not it's underlying object in case of a throw. ...
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.
RCPNode * ArrayRCP_createNewRCPNodeRawPtr(T *p, bool has_ownership_in)
Range error exception class.
#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 ...
size_type upperOffset_
Upper offset to the data; -1 if this array is null.
RCPNodeHandle create_weak() const
Return a weak handle.
bool operator==(BigUInt< n > const &a, BigUInt< n > const &b)
bool is_null() const
True if the underlying pointer is null, else false.
~ArcpReinterpretCastEmbeddedObj()
T * get() const
Get the raw C++ pointer to the underlying object.
Definition of Teuchos::as, for conversions between types.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
#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...
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...
void assign(size_type n, const T &val)
Resize and assign n elements of val.
ArrayView< T > view(size_type lowerOffset, size_type size) const
Return a nonpersisting view of a contiguous range of elements.