#include <shared_array.h>
|
typedef T | element_type |
| The allocator used to manage new/delete of mpRefCount.
|
|
typedef T *(this_type::* | bool_) () const |
|
template<typename T, typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
class eastl::shared_array< T, Allocator, Deleter >
class shared_array A shared_array is the same as shared_ptr but for arrays.
◆ bool_
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
Implicit operator bool Allows for using a scoped_ptr as a boolean. Example usage: shared_array<int> ptr = new int(3); if(ptr) ++*ptr;
Note that below we do not use operator bool(). The reason for this is that booleans automatically convert up to short, int, float, etc. The result is that this: if(sharedArray == 1) would yield true (bad).
◆ ref_count
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
ref_count An internal reference count type. Must be convertable to int so that the public use_count function can work.
◆ this_type
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
this_type This is an alias for shared_array<T>, this class.
◆ shared_array() [1/2]
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
shared_array Takes ownership of the pointer and sets the reference count to the pointer to 1. It is OK if the input pointer is null. The shared reference count is allocated on the heap via operator new. If an exception occurs during the allocation of the shared reference count, the owned pointer is deleted and the exception is rethrown. A null pointer is given a reference count of 1.
◆ shared_array() [2/2]
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
shared_array Shares ownership of a pointer with another instance of shared_array. This function increments the shared reference count on the pointer. If we want a shared_array constructor that is templated on shared_array, then we need to make it in addition to this function, as otherwise the compiler will generate this function and things will go wrong.
◆ ~shared_array()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
~shared_array Decrements the reference count for the owned pointer. If the reference count goes to zero, the owned pointer is deleted and the shared reference count is deleted.
◆ get()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
get Returns the owned pointer. Note that this class does not provide an operator T() function. This is because such a thing (automatic conversion) is deemed unsafe. Example usage: struct X{ void DoSomething(); }; shared_array<int> ptr = new X; X* pX = ptr.get(); pX->DoSomething();
◆ get_allocator()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
get_allocator Returns the memory allocator associated with this class.
◆ operator!()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator! This returns the opposite of operator bool; it returns true if the owned pointer is null. Some compilers require this and some don't. shared_array<int> ptr = new int(3); if(!ptr) assert(false);
◆ operator*()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator* Returns the owner pointer dereferenced. Example usage: shared_array<int> ptr = new int(3); int x = *ptr;
◆ operator->()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator-> Allows access to the owned pointer via operator->() Example usage: struct X{ void DoSomething(); }; shared_array<int> ptr = new X; ptr->DoSomething();
◆ operator=() [1/2]
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator= Copies another shared_array to this object. Note that this object may already own a shared pointer with another different pointer (but still of the same type) before this call. In that case, this function releases the old pointer, decrementing its reference count and deleting it if zero, takes shared ownership of the new pointer and increments its reference count. If we want a shared_array operator= that is templated on shared_array, then we need to make it in addition to this function, as otherwise the compiler will generate this function and things will go wrong.
◆ operator=() [2/2]
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator= Assigns a new pointer, while decrementing the reference count on the current pointer. The new pointer can be NULL and the current pointer can NULL. If the new pointer is equivalent to the current pointer, then nothing is done.
◆ operator[]()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
operator[] Returns a reference to the specified item in the owned pointer array. Example usage: shared_array<int> ptr = new int[6]; int x = ptr[2];
◆ reset()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
reset Releases the owned pointer and takes ownership of the passed in pointer. If the passed in pointer is the same as the owned pointer, nothing is done. The passed in pointer can be null, in which case the use count is set to 1.
◆ set_allocator()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
set_allocator Sets the memory allocator associated with this class.
◆ swap()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
swap Exchanges the owned pointer beween two shared_array objects.
◆ unique()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
unique Returns true if the reference count on the owned pointer is one. The return value is true if the owned pointer is null.
◆ use_count()
template<typename T , typename Allocator = EASTLAllocatorType, typename Deleter = smart_array_deleter<T>>
use_count Returns the reference count on the owned pointer. The return value is one if the owned pointer is null.
The documentation for this class was generated from the following file: