tenno 0.1.0
Loading...
Searching...
No Matches
tenno::weak_ptr< T > Class Template Reference

A weak pointer. More...

#include <memory.hpp>

Public Types

using element_type = T
 The type of the object to point to.
 

Public Member Functions

constexpr weak_ptr () noexcept
 Default constructor.
 
 weak_ptr (const weak_ptr &r) noexcept
 Copy constructor.
 
 weak_ptr (weak_ptr &&r) noexcept
 Move constructor.
 
 weak_ptr (const tenno::shared_ptr< T > &r) noexcept
 Construct a new weak pointer object.
 
 ~weak_ptr ()
 Destructor.
 
weak_ptroperator= (const weak_ptr &r) noexcept
 Copy assignment operator.
 
weak_ptroperator= (const shared_ptr< T > &r) noexcept
 Move assignment operator.
 
weak_ptroperator= (weak_ptr &&r) noexcept
 Move assignment operator.
 
void reset () noexcept
 Reset the weak pointer.
 
void swap (weak_ptr &r) noexcept
 Swap the weak pointer with another weak pointer.
 
long use_count () const noexcept
 Get the number of shared pointers pointing to the object.
 
bool expired () const noexcept
 Check if the weak pointer is empty.
 
tenno::shared_ptr< T > lock () const noexcept
 Lock the weak pointer.
 
template<class Y >
bool owner_before (const weak_ptr< Y > &other) const noexcept
 Stored value ordering.
 
template<class Y >
bool owner_before (const tenno::shared_ptr< Y > &other) const noexcept
 Stored value ordering.
 
template<class Y >
bool owner_equal (const tenno::shared_ptr< Y > &other) const noexcept
 Stored value equality.
 

Detailed Description

template<typename T>
class tenno::weak_ptr< T >

A weak pointer.

Template Parameters
TThe type of the object to point to

Definition at line 530 of file memory.hpp.

Member Typedef Documentation

◆ element_type

template<typename T >
using tenno::weak_ptr< T >::element_type = T

The type of the object to point to.

Definition at line 536 of file memory.hpp.

Constructor & Destructor Documentation

◆ weak_ptr() [1/4]

template<typename T >
tenno::weak_ptr< T >::weak_ptr ( )
inlineconstexprnoexcept

Default constructor.

Definition at line 541 of file memory.hpp.

◆ weak_ptr() [2/4]

template<typename T >
tenno::weak_ptr< T >::weak_ptr ( const weak_ptr< T > & r)
inlinenoexcept

Copy constructor.

Parameters
rThe weak pointer to copy

Definition at line 552 of file memory.hpp.

◆ weak_ptr() [3/4]

template<typename T >
tenno::weak_ptr< T >::weak_ptr ( weak_ptr< T > && r)
inlinenoexcept

Move constructor.

Parameters
rThe weak pointer to move

Definition at line 570 of file memory.hpp.

◆ weak_ptr() [4/4]

template<typename T >
tenno::weak_ptr< T >::weak_ptr ( const tenno::shared_ptr< T > & r)
inlinenoexcept

Construct a new weak pointer object.

Parameters
rThe shared pointer to copy

Definition at line 589 of file memory.hpp.

◆ ~weak_ptr()

template<typename T >
tenno::weak_ptr< T >::~weak_ptr ( )
inline

Destructor.

Definition at line 606 of file memory.hpp.

Member Function Documentation

◆ expired()

template<typename T >
bool tenno::weak_ptr< T >::expired ( ) const
inlinenoexcept

Check if the weak pointer is empty.

Returns
true If the weak pointer is empty
false If the weak pointer is not empty

Definition at line 757 of file memory.hpp.

◆ lock()

template<typename T >
tenno::shared_ptr< T > tenno::weak_ptr< T >::lock ( ) const
inlinenoexcept

Lock the weak pointer.

Returns
shared_ptr<T> The shared pointer to the object

Definition at line 769 of file memory.hpp.

◆ operator=() [1/3]

template<typename T >
weak_ptr & tenno::weak_ptr< T >::operator= ( const shared_ptr< T > & r)
inlinenoexcept

Move assignment operator.

Parameters
rThe weak pointer to move
Returns
weak_ptr& The moved weak pointer

Definition at line 657 of file memory.hpp.

◆ operator=() [2/3]

template<typename T >
weak_ptr & tenno::weak_ptr< T >::operator= ( const weak_ptr< T > & r)
inlinenoexcept

Copy assignment operator.

Parameters
rThe weak pointer to copy
Returns
weak_ptr& The copied weak pointer

Definition at line 626 of file memory.hpp.

◆ operator=() [3/3]

template<typename T >
weak_ptr & tenno::weak_ptr< T >::operator= ( weak_ptr< T > && r)
inlinenoexcept

Move assignment operator.

Parameters
rThe weak pointer to move
Returns
weak_ptr& The moved weak pointer

Definition at line 688 of file memory.hpp.

◆ owner_before() [1/2]

template<typename T >
template<class Y >
bool tenno::weak_ptr< T >::owner_before ( const tenno::shared_ptr< Y > & other) const
inlinenoexcept

Stored value ordering.

Parameters
otherThe shared pointer to compare with
Returns
true If the weak pointer is before the other shared pointer
false If the weak pointer is after the other shared pointer

Definition at line 806 of file memory.hpp.

◆ owner_before() [2/2]

template<typename T >
template<class Y >
bool tenno::weak_ptr< T >::owner_before ( const weak_ptr< Y > & other) const
inlinenoexcept

Stored value ordering.

Parameters
otherThe weak pointer to compare with
Returns
true If the weak pointer is before the other weak pointer
false If the weak pointer is after the other weak pointer

Definition at line 787 of file memory.hpp.

◆ owner_equal()

template<typename T >
template<class Y >
bool tenno::weak_ptr< T >::owner_equal ( const tenno::shared_ptr< Y > & other) const
inlinenoexcept

Stored value equality.

Parameters
otherThe weak pointer to compare with
Returns
true If the weak pointer is equal to the other weak pointer
false If the weak pointer is not equal to the other weak pointer

Definition at line 819 of file memory.hpp.

◆ reset()

template<typename T >
void tenno::weak_ptr< T >::reset ( )
inlinenoexcept

Reset the weak pointer.

Definition at line 716 of file memory.hpp.

◆ swap()

template<typename T >
void tenno::weak_ptr< T >::swap ( weak_ptr< T > & r)
inlinenoexcept

Swap the weak pointer with another weak pointer.

Parameters
rThe weak pointer to swap with

Definition at line 729 of file memory.hpp.

◆ use_count()

template<typename T >
long tenno::weak_ptr< T >::use_count ( ) const
inlinenoexcept

Get the number of shared pointers pointing to the object.

Returns
long The number of shared pointers pointing to the object

Definition at line 744 of file memory.hpp.


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