StackPtr

StackPtr class

Stack pointer. This type is a pointer to manage other object’s deletion. It should be allocated on stack and passed to functions either by value or by const reference.

template<typename T>class StackPtr : public System::SmartPtr<Stack<T>>

Template parameters

ParameterDescription
TElement type.

Methods

MethodDescription
auto begin()Accessor for begin() method of an underling collection. Only compiles if SmartPtr_ is specialization type with begin() method.
auto begin() constAccessor for begin() method of an underling collection. Only compiles if SmartPtr_ is specialization type with begin() method.
std::enable_if_t<std::is_same<Y, T>::value, SmartPtr<Y>> Cast() constCasts pointer to its type itself.
std::enable_if_t<!std::is_same<Y, T>::value&&std::is_base_of<Y, T>::value, SmartPtr<Y>> Cast() constCasts pointer to base type using static_cast.
std::enable_if_t<Check::value&&!std::is_same<Y, T>::value&&!std::is_base_of<Y, T>::value, SmartPtr<Y>> Cast() constCasts pointer to derived type dynamic_cast.
std::enable_if_t<!Check::value&&!std::is_same<Y, T>::value&&!std::is_base_of<Y, T>::value, SmartPtr<Y>> Cast() constCasts pointer to derived type dynamic_cast.
auto cbegin() constAccessor for cbegin() method of an underling collection. Only compiles if SmartPtr_ is specialization type with cbegin() method.
auto cend() constAccessor for cend() method of an underling collection. Only compiles if SmartPtr_ is specialization type with cend() method.
SmartPtr<Y> const_pointer_cast() constCasts pointer to different type using const_cast on pointed object.
SmartPtr<Y> dynamic_pointer_cast() constCasts pointer to different type using dynamic_cast on pointed object.
auto end()Accessor for end() method of an underling collection. Only compiles if SmartPtr_ is specialization type with end() method.
auto end() constAccessor for end() method of an underling collection. Only compiles if SmartPtr_ is specialization type with end() method.
Pointee_ * get() constGets pointed object.
SmartPtrMode get_Mode() constGets pointer mode.
Pointee_ * get_shared() constGets pointed object, but asserts that pointer is in shared mode.
int get_shared_count() constGets number of shared pointers existing to referenced object, including current one. Asserts current pointer being in shared mode.
int GetHashCode() constCalls GetHashCode() on pointed object.
T * GetObjectNotNull() constGets currently referenced object (if any) or throws.
Object * GetObjectOrNull() constGets pointed object (if any) or nullptr. Same as get().
Object * GetObjectOwner() constGets referenced object.
Pointee_ * GetPointer() constGets pointed object (if any) or nullptr. Same as get().
bool Is(const System::TypeInfo&) constChecks if pointed object is of specific type or its child type. Follows C# ‘is’ semantics.
bool IsAliasingPtr() constChecks if pointer is pointed to another object than owned (created by an aliasing constructor).
bool IsShared() constChecks if pointer is in shared mode.
bool IsWeak() constChecks if pointer is in weak mode.
explicit operator bool() constChecks if pointer is not null.
bool operator!() constChecks if pointer is null.
Pointee_& operator*() constGets reference to pointed object. Asserts that pointer is not null.
Pointee_ * operator->() constAllows to access members of referenced object.
bool operator<(Y *) constProvides less-compare semantics for SmartPtr class.
bool operator<(SmartPtr<Y> const&) constProvides less-compare semantics for SmartPtr class.
SmartPtr_& operator=(SmartPtr_&&)Move-assigns SmartPtr object. x becomes unusable.
SmartPtr_& operator=(const SmartPtr_&)Copy-assigns SmartPtr object.
SmartPtr_& operator=(const SmartPtr<Q>&)Copy-assigns SmartPtr object. Does required type conversions.
SmartPtr_& operator=(Pointee_ *)Assigns raw pointer to SmartPtr object.
SmartPtr_& operator=(std::nullptr_t)Sets pointer value to nullptr.
bool operator==(std::nullptr_t) constChecks if pointer points to nullptr.
SmartPtr_ RemoveAliasing() constRemoves aliasing (created by an aliasing constructor) from pointer, makes sure it manages (if shared) or tracks (if weak) the same object it points to.
void reset(Pointee_ *)Sets pointed object.
void reset()Makes pointer pointing to nullptr.
void set_Mode(SmartPtrMode)Sets pointer mode. May alter referenced object’s reference counts.
void SetContainedTemplateWeakPtr(uint32_t) constCalls SetTemplateWeakPtr() method on pointed object (if any).
SmartPtr(SmartPtrMode)Creates SmartPtr object of required mode.
SmartPtr(std::nullptr_t, SmartPtrMode)Creates null-pointer SmartPtr object of required mode.
SmartPtr(Pointee_ *, SmartPtrMode)Creates SmartPtr pointing to specified object, or converts raw pointer to SmartPtr.
SmartPtr(const SmartPtr_&, SmartPtrMode)Copy constructs SmartPtr object. Both pointers point to the same object afterwards.
SmartPtr(const SmartPtr<Q>&, SmartPtrMode)Copy constructs SmartPtr object. Both pointers point to the same object afterwards. Performs type conversion if allowed.
SmartPtr(SmartPtr_&&, SmartPtrMode)Move constructs SmartPtr object. Effectively, swaps two pointers, if they are both of same mode. x may be unusable after call.
explicit SmartPtr(const SmartPtr<Array<Y>>&, SmartPtrMode)Converts type of referenced array by creating a new array of different type. Useful if in C# there is an array type cast which is unsupported in C++.
explicit SmartPtr(const Y&)Initializes empty array. Used to translate some C# code constructs.
SmartPtr(const SmartPtr<P>&, Pointee_ *, SmartPtrMode)Constructs a SmartPtr which shares ownership information with the initial value of ptr, but holds an unrelated and unmanaged pointer p.
StackPtr()Constructs null pointer.
StackPtr(const SharedPtr<Stack<T>>&)Constructs pointer referencing specific stack.
SmartPtr<Y> static_pointer_cast() constCasts pointer to different type using static_cast on pointed object.
SmartPtr<Object> ToObjectPtr() constConverts any pointer type to pointer to Object. Doesn’t require Pointee_ type to be complete.
static const System::TypeInfo& Type()Shortcut to get System::TypeInfo object for the Pointee_ type.
~SmartPtr()Destroys SmartPtr object. If required, decreases pointed object’s reference counter and deletes object.

See Also