3ds Max C++ API Reference
ArrayAutoPtr< Type > Class Template Reference

Standard implementation of a AutoPtr for pointer to array types. More...

#include <autoptr.h>

+ Inheritance diagram for ArrayAutoPtr< Type >:

Public Member Functions

 ArrayAutoPtr (Type *p=NULL)
 Construct, assuming ownership of the pointed-to object. More...
 
 ArrayAutoPtr (const AutoPtrRef< Type > &ref)
 Construct from an AutoPtrRef. More...
 
template<typename OtherType >
 operator ArrayAutoPtr< OtherType > ()
 Destructive copy-convert allowing for cast of the pointer type. More...
 
Type & operator[] (int index) const
 Convenience array-index operator for ArrayAutoPtrs. More...
 
- Public Member Functions inherited from AutoPtr< Type, ArrayPointerDestructor< Type > >
 AutoPtr (Type *p=NULL)
 Construct, assuming ownership of the pointed-to object. More...
 
 AutoPtr (AutoPtr &a)
 Copy construct, assuming ownership from the source AutoPtr. More...
 
 AutoPtr (AutoPtr< OtherType, ArrayPointerDestructor< Type > > &a)
 Conversion copy constructor. More...
 
 AutoPtr (const AutoPtrRef< Type > &ref)
 Construct from an AutoPtrRef. More...
 
 ~AutoPtr ()
 Destructor - automatically cleans up the pointed-to object. More...
 
AutoPtroperator= (const AutoPtr &a)
 Assignment, takes over ownership from the source AutoPtr. More...
 
AutoPtroperator= (AutoPtr< OtherType, ArrayPointerDestructor< Type > > &a)
 Conversion assignment, takes over ownership of any type assignable to type from the source AutoPtr. More...
 
Type & operator* () const
 Dereferencing operator - works exactly like a plain pointer's operator*. More...
 
Type * operator-> () const
 Pointer-to-member dereferencing operator - works exactly like a plain pointer's operator->. More...
 
Type * Get () const
 Get the plain pointer back. More...
 
Type * Release ()
 Relinquish ownership of the pointed-to object to the caller. More...
 
void Reset (Type *p=NULL)
 Assume ownership of a new object, any existing pointer will be deleted. More...
 
bool IsNull () const
 Addition to the textbook interface. More...
 
 operator AutoPtrRef< OtherType > ()
 Convert to an AutoPtrRef. More...
 
 operator AutoPtr< OtherType, ArrayPointerDestructor< Type > > ()
 Destructive copy-convert allowing for cast of the pointer type. More...
 

Additional Inherited Members

- Public Types inherited from AutoPtr< Type, ArrayPointerDestructor< Type > >
typedef Type element_type
 Typedef to make the element type a member of the class. More...
 
typedef ArrayPointerDestructor< Type > destructor
 Typedef to make the DestructionPolicy type a member of the class. More...
 

Detailed Description

template<typename Type>
class MaxSDK::ArrayAutoPtr< Type >

Standard implementation of a AutoPtr for pointer to array types.

This ArrayAutoPtr template is appropriate for any pointer to a dynamically allocated array (using new [] and delete []). To manage a single dynamically allocated object, use AutoPtr instead.

Please refer to AutoPtr's documentation for more information about AutoPtrs.

Constructor & Destructor Documentation

◆ ArrayAutoPtr() [1/2]

ArrayAutoPtr ( Type *  p = NULL)
inlineexplicit

Construct, assuming ownership of the pointed-to object.

Parameters
pPlain pointer to an array - this AutoPtr will assume ownership of that object.
397  :
398  AutoPtr<Type, ArrayPointerDestructor<Type> >(p)
399  { };

◆ ArrayAutoPtr() [2/2]

ArrayAutoPtr ( const AutoPtrRef< Type > &  ref)
inline

Construct from an AutoPtrRef.

This may be done implicitly or explicitly. The Ref object exists to avoid temporarily needing to have two AutoPtrs own the same object.

Parameters
refhelper object.
408  :
409  AutoPtr<Type, ArrayPointerDestructor<Type> >(ref.mPtr)
410  { }

Member Function Documentation

◆ operator ArrayAutoPtr< OtherType >()

operator ArrayAutoPtr< OtherType > ( )
inline

Destructive copy-convert allowing for cast of the pointer type.

416  {
417  return ArrayAutoPtr<OtherType>(this->Release());
418  }
Type * Release()
Relinquish ownership of the pointed-to object to the caller.
Definition: autoptr.h:311

◆ operator[]()

Type& operator[] ( int  index) const
inline

Convenience array-index operator for ArrayAutoPtrs.

Using this operator is the same as calling Get()[index]. Note that this operator does not check if the index is out of bounds. This is not a bounds checking smart pointer, it's just a handy guard object for dealing with memory ownership.

Precondition
index must be within the underlying array's bounds.
Parameters
indexThe index within the array
Returns
a reference to the element at position index in the array.
433  {
434  return this->Get()[index];
435  }
Type * Get() const
Get the plain pointer back.
Definition: autoptr.h:300