Nugget
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
eastl::scoped_array< T, Deleter > Class Template Reference

#include <scoped_array.h>

Public Types

typedef T element_type
 
typedef T *(this_type::* bool_) () const
 

Public Member Functions

 scoped_array (T *pArray=NULL)
 
 ~scoped_array ()
 
void reset (T *pArray=NULL)
 
T * detach ()
 
void swap (this_type &scopedArray)
 
add_lvalue_reference< T >::type operator[] (ptrdiff_t i) const
 
T * get () const
 
 operator bool_ () const
 
bool operator! () const
 

Protected Types

typedef scoped_array< T > this_type
 
typedef Deleter deleter_type
 deleter_type
 

Protected Member Functions

 scoped_array (const scoped_array &)
 
scoped_arrayoperator= (const scoped_array &)
 
scoped_arrayoperator= (T *pValue)
 

Protected Attributes

T * mpArray
 

Detailed Description

template<typename T, typename Deleter = smart_array_deleter<T>>
class eastl::scoped_array< T, Deleter >

class scoped_array

A scoped_array is the same as scoped_ptr but for arrays.

Member Typedef Documentation

◆ bool_

template<typename T , typename Deleter = smart_array_deleter<T>>
typedef T*(this_type::* eastl::scoped_array< T, Deleter >::bool_) () const

Implicit operator bool Allows for using a scoped_ptr as a boolean. Example usage: scoped_array<int> ptr(new int[8]); if(ptr) ++ptr[2];

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(scopedArray == 1) would yield true (bad).

◆ this_type

template<typename T , typename Deleter = smart_array_deleter<T>>
typedef scoped_array<T> eastl::scoped_array< T, Deleter >::this_type
protected

this_type This is an alias for scoped_array<T>, this class.

Constructor & Destructor Documentation

◆ scoped_array() [1/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::scoped_array< T, Deleter >::scoped_array ( const scoped_array< T, Deleter > &  )
protected

scoped_array This function is private in order to prevent copying, for safety.

◆ scoped_array() [2/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::scoped_array< T, Deleter >::scoped_array ( T *  pArray = NULL)
inlineexplicit

scoped_ptr Construct a scoped_ptr from a pointer allocated via new. Example usage: scoped_array<int> ptr(new int[6]);

◆ ~scoped_array()

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::scoped_array< T, Deleter >::~scoped_array ( )
inline

~scoped_array Destroys the owned pointer. The destructors for each of the objects in the owned array will be called.

Member Function Documentation

◆ detach()

template<typename T , typename Deleter = smart_array_deleter<T>>
T* eastl::scoped_array< T, Deleter >::detach ( )
inline

detach This simply forgets the owned pointer. It doesn't free it but rather assumes that the user does. Example usage: scoped_array<int> ptr(new int[6]); int* pIntArray = ptr.get(); ptr.detach(); delete[] pIntArray;

◆ get()

template<typename T , typename Deleter = smart_array_deleter<T>>
T* eastl::scoped_array< T, Deleter >::get ( ) const
inline

get Returns the owned array pointer. Example usage: struct X{ void DoSomething(); }; scoped_array<int> ptr(new X[8]); X** ppX = ptr.get(); ppX[2]->DoSomething();

◆ operator!()

template<typename T , typename Deleter = smart_array_deleter<T>>
bool eastl::scoped_array< T, Deleter >::operator! ( ) const
inline

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. scoped_array<int> ptr(new int(3)); if(!ptr) assert(false);

◆ operator=() [1/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
scoped_array& eastl::scoped_array< T, Deleter >::operator= ( const scoped_array< T, Deleter > &  )
protected

scoped_array This function is private in order to prevent copying, for safety.

◆ operator=() [2/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
scoped_array& eastl::scoped_array< T, Deleter >::operator= ( T *  pValue)
protected

scoped_ptr This function is private in order to prevent copying, for safety.

◆ operator[]()

template<typename T , typename Deleter = smart_array_deleter<T>>
add_lvalue_reference<T>::type eastl::scoped_array< T, Deleter >::operator[] ( ptrdiff_t  i) const
inline

operator[] Returns a reference to the specified item in the owned pointer array. Example usage: scoped_array<int> ptr(new int[6]); int x = ptr[2];

◆ reset()

template<typename T , typename Deleter = smart_array_deleter<T>>
void eastl::scoped_array< T, Deleter >::reset ( T *  pArray = NULL)
inline

reset Deletes 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. Example usage: scoped_array<int> ptr(new int[6]); ptr.reset(new int[7]); // deletes int[6] ptr.reset(NULL); // deletes int[7]

◆ swap()

template<typename T , typename Deleter = smart_array_deleter<T>>
void eastl::scoped_array< T, Deleter >::swap ( this_type scopedArray)
inline

swap Exchanges the owned pointer beween two scoped_array objects.

Member Data Documentation

◆ mpArray

template<typename T , typename Deleter = smart_array_deleter<T>>
T* eastl::scoped_array< T, Deleter >::mpArray
protected

mpArray The owned pointer. Points to an array of T.


The documentation for this class was generated from the following file: