43 #ifndef TEUCHOS_ARRAY_RCP_DECL_HPP 44 #define TEUCHOS_ARRAY_RCP_DECL_HPP 165 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 241 template<
class Dealloc_T>
260 inline explicit ArrayRCP( size_type
size,
const T& val = T() );
353 inline T*
get()
const;
475 inline iterator
begin()
const;
487 inline iterator
end()
const;
529 inline size_type
size()
const;
582 inline void assign(size_type
n,
const T &val);
592 inline void assign(Iter first, Iter last);
602 inline void resize(
const size_type
n,
const T &val = T());
783 inline TEUCHOS_DEPRECATED
int count()
const;
798 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL 805 size_type size_in)
const 807 (void) lowerOffset_in;
809 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 822 #ifndef DOXYGEN_COMPILE 829 T* access_private_ptr()
const;
859 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 871 template<
class Dealloc_T>
874 inline explicit ArrayRCP (size_type size,
const T& val = T ());
882 inline const T*
get()
const;
884 inline const T&
operator[] (size_type offset)
const;
895 inline iterator
begin()
const;
896 inline iterator
end()
const;
908 inline size_type
size()
const;
914 inline void resize (
const size_type
n,
const T& val = T ());
915 inline void clear ();
935 inline TEUCHOS_DEPRECATED
int count()
const;
944 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL 951 size_type size_in)
const 953 (void) lowerOffset_in; (void) size_in;
954 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 967 #ifndef DOXYGEN_COMPILE 974 const T* access_private_ptr()
const;
1044 template<
typename T>
1061 bool owns_mem =
true 1070 template<
class T,
class Dealloc_T>
1075 Dealloc_T dealloc,
bool owns_mem
1128 template<
class T,
class Embedded>
1134 const Embedded &embedded,
1135 bool owns_mem =
true 1149 template<
class T,
class Embedded>
1155 const Embedded &embedded,
1156 bool owns_mem =
true 1171 template<
class T,
class Embedded>
1177 const Embedded &embedded,
1178 bool owns_mem =
true 1268 template<
class T1,
class T2>
1276 template<
class T1,
class T2>
1284 template<
class T1,
class T2>
1285 bool operator<( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 );
1292 template<
class T1,
class T2>
1293 bool operator<=( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 );
1300 template<
class T1,
class T2>
1308 template<
class T1,
class T2>
1331 template<
class T2,
class T1>
1347 template<
class T2,
class T1>
1367 template<
class T2,
class T1>
1396 template<
class T2,
class T1>
1459 template<
class T1,
class T2>
1461 const T1 &extra_data,
const std::string& name,
1463 bool force_unique =
true );
1485 template<
class T1,
class T2>
1514 template<
class T1,
class T2>
1542 template<
class T1,
class T2>
1575 template<
class T1,
class T2>
1589 template<
class Dealloc_T,
class T>
1610 template<
class Dealloc_T,
class T>
1628 template<
class Dealloc_T,
class T>
1653 template<
class Dealloc_T,
class T>
1663 template<
class TOrig,
class Embedded,
class T>
1673 template<
class TOrig,
class Embedded,
class T>
1685 std::ostream& operator<<( std::ostream& out, const ArrayRCP<T>& p );
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'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...
const void * const_pointer
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.
void debug_assert_not_null() const
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.
const T & const_reference
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.
static ArrayRCP< T > getNull()
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.
void debug_assert_valid_ptr() const
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'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.
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.
const void * iterator_type
Handle class that manages the RCPNode'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.