Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::Scope< T > Class Template Reference

Exclusive-ownership smart pointer. More...

#include <Scope.h>

Public Member Functions

 Scope (T *ptr=nullptr) noexcept
 Constructs an empty Scope or takes ownership of ptr.
template<typename T2, typename = std::enable_if_t<std::is_base_of_v<T, T2>>>
 Scope (Scope< T2 > &&other) noexcept
 Move constructor from compatible Scope<T2>.
 Scope (const Scope &)=delete
Scopeoperator= (const Scope &)=delete
 ~Scope ()
 Destructor. Deletes managed object if not null.
 Scope (Scope &&other) noexcept
 Move constructor.
Scopeoperator= (Scope &&other) noexcept
 Move assignment operator.
T * Release () noexcept
 Releases ownership of the managed pointer.
void Reset (T *ptr=nullptr) noexcept
 Resets the managed pointer to ptr.
T * Get () const noexcept
 Gets the raw managed pointer.
T & operator* () const
 Dereference operator.
T * operator-> () const noexcept
 Arrow operator.
 operator bool () const noexcept
 Bool conversion. True if managing a non-null pointer.
constexpr bool operator== (const Scope &other) const noexcept
 Equality comparison between scopes.
constexpr bool operator!= (const Scope &other) const noexcept
constexpr bool operator< (const Scope &other) const noexcept
 Comparison operators for ordering.
constexpr bool operator<= (const Scope &other) const noexcept
constexpr bool operator> (const Scope &other) const noexcept
constexpr bool operator>= (const Scope &other) const noexcept
template<typename T2>
Scope< T2 > CastTo () &&noexcept
 Casts this Scope to Scope<T2> when T2 is base of T.

Friends

void swap (Scope &first, Scope &second) noexcept
 Swaps two Scope instances.

Detailed Description

template<typename T>
class Raven::Scope< T >

Exclusive-ownership smart pointer.

A minimal replacement for std::unique_ptr that uses rnew/rdelete and integrates with Raven's memory tracking. Supports move-only semantics and type-safe conversions between related types.

Template Parameters
TThe type of the managed object.

Constructor & Destructor Documentation

◆ Scope() [1/4]

template<typename T>
Raven::Scope< T >::Scope ( T * ptr = nullptr)
inlinenoexcept

Constructs an empty Scope or takes ownership of ptr.

Parameters
ptrRaw pointer to manage (default nullptr).

◆ Scope() [2/4]

template<typename T>
template<typename T2, typename = std::enable_if_t<std::is_base_of_v<T, T2>>>
Raven::Scope< T >::Scope ( Scope< T2 > && other)
inlinenoexcept

Move constructor from compatible Scope<T2>.

Template Parameters
T2Derived type of T.
Parameters
otherTemporary Scope<T2> to take ownership from.

◆ Scope() [3/4]

template<typename T>
Raven::Scope< T >::Scope ( const Scope< T > & )
delete

◆ ~Scope()

template<typename T>
Raven::Scope< T >::~Scope ( )
inline

Destructor. Deletes managed object if not null.

◆ Scope() [4/4]

template<typename T>
Raven::Scope< T >::Scope ( Scope< T > && other)
inlinenoexcept

Move constructor.

Parameters
otherScope to move from.

Member Function Documentation

◆ CastTo()

template<typename T>
template<typename T2>
Scope< T2 > Raven::Scope< T >::CastTo ( ) &&
inlinenoexcept

Casts this Scope to Scope<T2> when T2 is base of T.

Template Parameters
T2Target type.
Returns
Scope<T2> with transferred ownership.

◆ Get()

template<typename T>
T * Raven::Scope< T >::Get ( ) const
inlinenoexcept

Gets the raw managed pointer.

Returns
The raw pointer.

◆ operator bool()

template<typename T>
Raven::Scope< T >::operator bool ( ) const
inlineexplicitnoexcept

Bool conversion. True if managing a non-null pointer.

◆ operator!=()

template<typename T>
bool Raven::Scope< T >::operator!= ( const Scope< T > & other) const
inlineconstexprnoexcept

◆ operator*()

template<typename T>
T & Raven::Scope< T >::operator* ( ) const
inline

Dereference operator.

Returns
Reference to the managed object.

◆ operator->()

template<typename T>
T * Raven::Scope< T >::operator-> ( ) const
inlinenoexcept

Arrow operator.

Returns
The managed pointer.

◆ operator<()

template<typename T>
bool Raven::Scope< T >::operator< ( const Scope< T > & other) const
inlineconstexprnoexcept

Comparison operators for ordering.

◆ operator<=()

template<typename T>
bool Raven::Scope< T >::operator<= ( const Scope< T > & other) const
inlineconstexprnoexcept

◆ operator=() [1/2]

template<typename T>
Scope & Raven::Scope< T >::operator= ( const Scope< T > & )
delete

◆ operator=() [2/2]

template<typename T>
Scope & Raven::Scope< T >::operator= ( Scope< T > && other)
inlinenoexcept

Move assignment operator.

Parameters
otherScope to move from.
Returns
Reference to this.

◆ operator==()

template<typename T>
bool Raven::Scope< T >::operator== ( const Scope< T > & other) const
inlineconstexprnoexcept

Equality comparison between scopes.

◆ operator>()

template<typename T>
bool Raven::Scope< T >::operator> ( const Scope< T > & other) const
inlineconstexprnoexcept

◆ operator>=()

template<typename T>
bool Raven::Scope< T >::operator>= ( const Scope< T > & other) const
inlineconstexprnoexcept

◆ Release()

template<typename T>
T * Raven::Scope< T >::Release ( )
inlinenoexcept

Releases ownership of the managed pointer.

Returns
The raw pointer that was managed.

◆ Reset()

template<typename T>
void Raven::Scope< T >::Reset ( T * ptr = nullptr)
inlinenoexcept

Resets the managed pointer to ptr.

Parameters
ptrNew pointer to manage (default nullptr).

◆ swap

template<typename T>
void swap ( Scope< T > & first,
Scope< T > & second )
friend

Swaps two Scope instances.


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