StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::EnableSharedFromThis< T > Class Template Reference

Base that can recover a Shared from an object owned by one. More...

#include <StormByte/safe/pointers.hxx>

Public Member Functions

 EnableSharedFromThis () noexcept=default
 Construct an unlinked base.
 EnableSharedFromThis (const EnableSharedFromThis &other) noexcept
 Copy does not copy the observer.
 EnableSharedFromThis (EnableSharedFromThis &&other) noexcept
 Move does not move the observer.
EnableSharedFromThis & operator= (const EnableSharedFromThis &other) noexcept
 Assignment does not replace the observer.
EnableSharedFromThis & operator= (EnableSharedFromThis &&other) noexcept
 Move assignment does not replace the observer.
 ~EnableSharedFromThis ()=default
 Destroy the embedded observer.

Protected Member Functions

Shared< T > SharedFromThis () const
 Recover an owner of this object.

Friends

template<class U, class... Args>
Shared< U > MakeShared (Args &&...)

Detailed Description

template<class T>
class StormByte::Safe::EnableSharedFromThis< T >

Base that can recover a Shared from an object owned by one.

Template Parameters
TMost derived type used with MakeShared.

MakeShared links the embedded observer after construction. Calling SharedFromThis before that link throws ExpiredWeakPointerError.

Constructor & Destructor Documentation

◆ EnableSharedFromThis() [1/3]

template<class T>
StormByte::Safe::EnableSharedFromThis< T >::EnableSharedFromThis ( )
defaultnoexcept

Construct an unlinked base.

◆ EnableSharedFromThis() [2/3]

template<class T>
StormByte::Safe::EnableSharedFromThis< T >::EnableSharedFromThis ( const EnableSharedFromThis< T > & other)
noexcept

Copy does not copy the observer.

Parameters
otherIgnored.

◆ EnableSharedFromThis() [3/3]

template<class T>
StormByte::Safe::EnableSharedFromThis< T >::EnableSharedFromThis ( EnableSharedFromThis< T > && other)
noexcept

Move does not move the observer.

Parameters
otherIgnored.

◆ ~EnableSharedFromThis()

template<class T>
StormByte::Safe::EnableSharedFromThis< T >::~EnableSharedFromThis ( )
default

Destroy the embedded observer.

Member Function Documentation

◆ operator=() [1/2]

template<class T>
EnableSharedFromThis & StormByte::Safe::EnableSharedFromThis< T >::operator= ( const EnableSharedFromThis< T > & other)
noexcept

Assignment does not replace the observer.

Parameters
otherIgnored.
Returns
This base.

◆ operator=() [2/2]

template<class T>
EnableSharedFromThis & StormByte::Safe::EnableSharedFromThis< T >::operator= ( EnableSharedFromThis< T > && other)
noexcept

Move assignment does not replace the observer.

Parameters
otherIgnored.
Returns
This base.

◆ SharedFromThis()

template<class T>
Shared< T > StormByte::Safe::EnableSharedFromThis< T >::SharedFromThis ( ) const
protected

Recover an owner of this object.

Returns
Owner sharing the control block created by MakeShared.
Exceptions
ExpiredWeakPointerErrorThis object is not currently owned by a Shared.

◆ MakeShared

template<class T>
template<class U, class... Args>
Shared< U > MakeShared ( Args && ...)
friend

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