#include <Teuchos_ArrayRefCountPtrDecl.hpp>
Public Types | |
Public types | |
| typedef T | element_type |
| | |
| typedef Teuchos_Index | Ordinal |
| | |
Public Member Functions | |
Constructors/Initializers | |
| ArrayRefCountPtr (ENull null_arg=null) | |
Initialize ArrayRefCountPtr<T> to NULL. | |
| ArrayRefCountPtr (const ArrayRefCountPtr< T > &r_ptr) | |
Initialize from another ArrayRefCountPtr<T> object. | |
| ~ArrayRefCountPtr () | |
| Removes a reference to a dynamically allocated array and possibly deletes the array if owned. | |
| ArrayRefCountPtr< T > & | operator= (const ArrayRefCountPtr< T > &r_ptr) |
| Copy the pointer to the referenced array and increment the reference count. | |
Object/Pointer Access Functions | |
| T * | operator-> () const |
Pointer (->) access to members of underlying object for current position. | |
| T & | operator * () const |
| Dereference the underlying object for the current pointer position. | |
| T * | get () const |
| Get the raw C++ pointer to the underlying object. | |
| T & | operator[] (Ordinal offset) const |
| Random object access. | |
Pointer Arithmetic Functions | |
| ArrayRefCountPtr< T > & | operator++ () |
| Prefix increment of pointer (i.e. ++ptr). | |
| ArrayRefCountPtr< T > | operator++ (int) |
| Postfix increment of pointer (i.e. ptr++). | |
| ArrayRefCountPtr< T > & | operator-- () |
| Prefix deincrement of pointer (i.e. --ptr). | |
| ArrayRefCountPtr< T > | operator-- (int) |
| Postfix deincrement of pointer (i.e. ptr--). | |
| ArrayRefCountPtr< T > & | operator+= (Ordinal offset) |
| Pointer integer increment (i.e. ptr+=offset). | |
| ArrayRefCountPtr< T > & | operator-= (Ordinal offset) |
| Pointer integer increment (i.e. ptr-=offset). | |
| ArrayRefCountPtr< T > | operator+ (Ordinal offset) const |
| Pointer integer increment (i.e. ptr+offset). | |
| ArrayRefCountPtr< T > | operator- (Ordinal offset) const |
| Pointer integer deincrement (i.e. ptr-offset). | |
Views | |
| ArrayRefCountPtr< const T > | getConst () const |
| Return object for only const access to data. | |
| ArrayRefCountPtr< T > | subview (Ordinal lowerOffset, Ordinal size) const |
| Return a view of a contiguous range of elements. | |
General query functions | |
| int | count () const |
Return the number of ArrayRefCountPtr<> objects that have a reference to the underlying pointer that is being shared. | |
| template<class T2> | |
| bool | shares_resource (const ArrayRefCountPtr< T2 > &r_ptr) const |
| Returns true if the smart pointers share the same underlying reference-counted object. | |
| Ordinal | lowerOffset () const |
| Return the lower offset to valid data. | |
| Ordinal | upperOffset () const |
| Return the upper offset to valid data. | |
| Ordinal | size () const |
The total number of items in the managed array (i.e. upperOffset()-lowerOffset()+1). | |
Standard Container-Like Functions | |
| const_iterator | begin () const |
| Return an iterator to beginning of the array of data. | |
| const_iterator | end () const |
| Return an iterator to past the end of the array of data. | |
Ownership | |
| T * | release () |
| Release the ownership of the underlying array. | |
| void | set_has_ownership () |
Give this and other ArrayRefCountPtr<> objects ownership of the underlying referenced array to delete it. | |
| bool | has_ownership () const |
Returns true if this has ownership of object pointed to by this->get() in order to delete it. | |
Assertion Functions. | |
| const ArrayRefCountPtr< T > & | assert_not_null () const |
Throws std::logic_error if this->get()==NULL, otherwise returns reference to *this. | |
| const ArrayRefCountPtr< T > & | assert_in_range (Ordinal lowerOffset, Ordinal size) const |
Throws std::logic_error if this->get()==NULL orthis->get()!=NULL && (lowerOffset < this->lowerOffset() || this->upperOffset() < upperOffset, otherwise returns reference to *this. | |
Related Functions | |
| (Note that these are not member functions.) | |
| ArrayRefCountPtr< T > | arcp (T *p, typename ArrayRefCountPtr< T >::Ordinal lowerOffset, typename ArrayRefCountPtr< T >::Ordinal size, bool owns_mem=true) |
| Wraps a preallocated array of data with the assumption to call the array version of delete. | |
| ArrayRefCountPtr< T > | arcp (T *p, typename ArrayRefCountPtr< T >::Ordinal lowerOffset, typename ArrayRefCountPtr< T >::Ordinal size, Dealloc_T dealloc, bool owns_mem) |
| Wraps a preallocated array of data and uses a templated deallocation strategy object to define deletion . | |
| ArrayRefCountPtr< T > | arcp (typename ArrayRefCountPtr< T >::Ordinal size) |
| Allocate a new array just given a dimension. | |
| ArrayRefCountPtr< T > | arcp (const RefCountPtr< std::vector< T > > &v) |
Wrap an std::vector<T> object as an ArrayRefCountPtr<T> object. | |
| ArrayRefCountPtr< const T > | arcp (const RefCountPtr< const std::vector< T > > &v) |
Wrap a const std::vector<T> object as an ArrayRefCountPtr<const T> object. | |
| RefCountPtr< std::vector< T > > | get_std_vector (const ArrayRefCountPtr< T > &ptr) |
Get an std::vector<T> object out of an ArrayRefCountPtr<T> object that was created using the arcp() above to wrap the vector in the first place.. | |
| RefCountPtr< const std::vector< T > > | get_std_vector (const ArrayRefCountPtr< const T > &ptr) |
Get a const std::vector<T> object out of an ArrayRefCountPtr<const T> object that was created using the arcp() above to wrap the vector in the first place. | |
| bool | is_null (const ArrayRefCountPtr< T > &p) |
Returns true if p.get()==NULL. | |
| bool | operator== (const ArrayRefCountPtr< T > &p, ENull) |
Returns true if p.get()==NULL. | |
| bool | operator!= (const ArrayRefCountPtr< T > &p, ENull) |
Returns true if p.get()!=NULL. | |
| bool | operator== (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| bool | operator!= (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| bool | operator< (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| bool | operator<= (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| bool | operator> (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| bool | operator>= (const ArrayRefCountPtr< T1 > &p1, const ArrayRefCountPtr< T2 > &p2) |
| | |
| ArrayRefCountPtr< T2 > | arcp_reinterpret_cast (const ArrayRefCountPtr< T1 > &p1) |
Reinterpret cast of underlying ArrayRefCountPtr type from T1* to T2*. | |
| ArrayRefCountPtr< T2 > | arcp_implicit_cast (const ArrayRefCountPtr< T1 > &p1) |
Implicit case the underlying ArrayRefCountPtr type from T1* to T2*. | |
| void | set_extra_data (const T1 &extra_data, const std::string &name, ArrayRefCountPtr< T2 > *p, EPrePostDestruction destroy_when=POST_DESTROY, bool force_unique=true) |
Set extra data associated with a ArrayRefCountPtr object. | |
| T1 & | get_extra_data (ArrayRefCountPtr< T2 > &p, const std::string &name) |
Get a non-const reference to extra data associated with a ArrayRefCountPtr object. | |
| const T1 & | get_extra_data (const ArrayRefCountPtr< T2 > &p, const std::string &name) |
Get a const reference to extra data associated with a ArrayRefCountPtr object. | |
| T1 * | get_optional_extra_data (ArrayRefCountPtr< T2 > &p, const std::string &name) |
Get a pointer to non-const extra data (if it exists) associated with a ArrayRefCountPtr object. | |
| const T1 * | get_optional_extra_data (const ArrayRefCountPtr< T2 > &p, const std::string &name) |
Get a pointer to const extra data (if it exists) associated with a ArrayRefCountPtr object. | |
| Dealloc_T & | get_dealloc (ArrayRefCountPtr< T > &p) |
Return a non-const reference to the underlying deallocator object. | |
| const Dealloc_T & | get_dealloc (const ArrayRefCountPtr< T > &p) |
Return a const reference to the underlying deallocator object. | |
| Dealloc_T * | get_optional_dealloc (ArrayRefCountPtr< T > &p) |
Return a pointer to the underlying non-const deallocator object if it exists. | |
| const Dealloc_T * | get_optional_dealloc (const ArrayRefCountPtr< T > &p) |
Return a pointer to the underlying const deallocator object if it exists. | |
| std::ostream & | operator<< (std::ostream &out, const ArrayRefCountPtr< T > &p) |
| Output stream inserter. | |
This is a reference-counted class similar to RefCountPtr except that it is designed to use reference counting to manage an array of objects that use value semantics. Managing an array of objects is very different from managing a pointer to an individual, possibly polymorphic, object. For example, while implicit conversions from derived to base types is a good thing when dealing with pointers to single objects, it is a very bad thing when working with arrays of objects. Therefore, this class contains those capabilities of raw pointers that are good dealing with arrays of objects but excludes those that are bad, such as implicit conversions from derived to base types.
Note that all access will be checked at runtime to avoid reading invalid memory if HAVE_TEUCHOS_ARRAY_BOUNDSCHECK is defined which it is if --enable-teuchos-abc is given to the configure script. In order to be able to check access, every ArrayRefCountPtr must be constructed given a range. When HAVE_TEUCHOS_ARRAY_BOUNDSCHECK is defined, this class simply does not give up a raw pointer or raw reference to any internally referenced object if that object does not fall with the range of valid data.
ToDo: Finish documentation!
Definition at line 63 of file Teuchos_ArrayRefCountPtrDecl.hpp.
|
|||||
|
Definition at line 70 of file Teuchos_ArrayRefCountPtrDecl.hpp. |
|
|||||
|
Definition at line 72 of file Teuchos_ArrayRefCountPtrDecl.hpp. |
|
||||||||||
|
Initialize This allows clients to write code like: ArrayRefCountPtr<int> p = null; ArrayRefCountPtr<int> p; NULL
Definition at line 60 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Initialize from another
After construction, This form of the copy constructor is required even though the below more general templated version is sufficient since some compilers will generate this function automatically which will give an incorrect implementation. Postconditions:
Definition at line 69 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Removes a reference to a dynamically allocated array and possibly deletes the array if owned.
Deallocates array if Definition at line 79 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Copy the pointer to the referenced array and increment the reference count.
If Postconditions:
Definition at line 92 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Pointer ( Preconditions:
Definition at line 114 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Dereference the underlying object for the current pointer position. Preconditions:
Definition at line 124 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Get the raw C++ pointer to the underlying object. Preconditions:
Definition at line 134 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Random object access. Preconditions:
Definition at line 146 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Prefix increment of pointer (i.e. ++ptr).
Does nothing if Postconditions:
Definition at line 158 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Postfix increment of pointer (i.e. ptr++).
Does nothing if Postconditions:
Definition at line 170 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Prefix deincrement of pointer (i.e. --ptr).
Does nothing if Postconditions:
Definition at line 179 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Postfix deincrement of pointer (i.e. ptr--).
Does nothing if Postconditions:
Definition at line 191 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Pointer integer increment (i.e. ptr+=offset).
Does nothing if Postconditions:
Definition at line 200 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Pointer integer increment (i.e. ptr-=offset).
Does nothing if Postconditions:
Definition at line 212 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Pointer integer increment (i.e. ptr+offset).
Returns a null pointer if Postconditions:
Note that since implicit conversion of Definition at line 224 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||
|
Pointer integer deincrement (i.e. ptr-offset).
Returns a null pointer if Postconditions:
Note that since implicit conversion of Definition at line 233 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return object for only const access to data.
This function should compile only successfully if the type Definition at line 244 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||||||||
|
Return a view of a contiguous range of elements. Preconditions:
Postconditions:
Definition at line 253 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return the number of
Definition at line 269 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||||||
|
Returns true if the smart pointers share the same underlying reference-counted object.
This method does more than just check if Definition at line 278 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return the lower offset to valid data.
Definition at line 289 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return the upper offset to valid data.
Definition at line 297 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
The total number of items in the managed array (i.e.
Definition at line 305 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return an iterator to beginning of the array of data.
If Postconditions: Definition at line 314 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Return an iterator to past the end of the array of data.
If Postconditions:
Definition at line 326 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Release the ownership of the underlying array.
After this function is called then the client is responsible for deleting the returned pointer no matter how many
Note that this function does not have the exact same semantics as does Postconditions:
Definition at line 339 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Give
See Postconditions:
Definition at line 348 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Returns true if
See
Definition at line 356 of file Teuchos_ArrayRefCountPtr.hpp. |
|
|||||||||
|
Throws
Definition at line 368 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||||||||
|
Throws
Definition at line 377 of file Teuchos_ArrayRefCountPtr.hpp. |
|
||||||||||||||||||||||||
|
Wraps a preallocated array of data with the assumption to call the array version of delete.
|
|
||||||||||||||||||||||||||||
|
Wraps a preallocated array of data and uses a templated deallocation strategy object to define deletion .
|
|
||||||||||
|
Allocate a new array just given a dimension.
Warning! The memory is allocated using |
|
||||||||||
|
Wrap an
|
|
||||||||||
|
Wrap a
|
|
||||||||||
|
Get an
|
|
||||||||||
|
Get a
|
|
||||||||||
|
Returns true if
|
|
||||||||||||||||
|
Returns true if
|
|
||||||||||||||||
|
Returns true if
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||
|
Reinterpret cast of underlying
The function will compile only if ( Warning! Do not use this function unless you absolutely know what you are doing. Doing a reinterpret cast is always a tricking thing and must only be done by developers who are 100% comfortable with what they are doing. |
|
||||||||||
|
Implicit case the underlying
The function will compile only if (
Warning! Do not use this function unless you absolutely know what you are doing. While implicit casting of pointers to single objects is usually 100% safe, implicit casting pointers to arrays of objects can be very dangerous. One exception that is always safe is when you are implicit casting an array of pointers to non-const objects to an array of const pointers to const objects. For example, the following implicit conversion from a array pointer objects
ArrayRefCountPtr<const T * const>
aptr2 = arcp_implicit_cast<const T * const>(ptr1);
is always legal and safe to do. |
|
||||||||||||||||||||||||||||
|
Set extra data associated with a
T1 and same arguments p and name has already been made, then the current piece of extra data already set will be overwritten with extra_data. However, if the type of the extra data T1 is different, then the extra data can be added and not overwrite existing extra data. This means that extra data is keyed on both the type and name. This helps to minimize the chance that clients will unexpectedly overwrite data by accident.
When the last Preconditions:
Note, this function is made a non-member function to be consistent with the non-member |
|
||||||||||||||||
|
Get a non-const reference to extra data associated with a
Note, this function must be a non-member function since the client must manually select the first template argument. |
|
||||||||||||||||
|
Get a const reference to extra data associated with a
Note, this function must be a non-member function since the client must manually select the first template argument.
Also note that this const version is a false sense of security since a client can always copy a const |
|
||||||||||||||||
|
Get a pointer to non-const extra data (if it exists) associated with a
Postconditions:
Note, this function must be a non-member function since the client must manually select the first template argument. |
|
||||||||||||||||
|
Get a pointer to const extra data (if it exists) associated with a
Postconditions:
Note, this function must be a non-member function since the client must manually select the first template argument.
Also note that this const version is a false sense of security since a client can always copy a const |
|
||||||||||
|
Return a non- Preconditions:
|
|
||||||||||
|
Return a Preconditions:
Note that the |
|
||||||||||
|
Return a pointer to the underlying non- Preconditions:
Postconditions:
|
|
||||||||||
|
Return a pointer to the underlying Preconditions:
Postconditions:
Note that the |
|
||||||||||||||||
|
Output stream inserter. The implementation of this function just print pointer addresses and therefore puts not restrictions on the data types involved. |
1.3.9.1