cycle_ptr
Public Types | Public Member Functions | Friends | Related Functions | List of all members
cycle_ptr::cycle_weak_ptr< T > Class Template Reference

Weak cycle pointer. More...

#include <cycle_ptr.h>

Public Types

using element_type = std::remove_extent_t< T >
 Element type of this pointer. More...
 

Public Member Functions

constexpr cycle_weak_ptr () noexcept
 Default constructor.
 
 cycle_weak_ptr (const cycle_weak_ptr &other) noexcept
 Copy constructor.
 
 cycle_weak_ptr (cycle_weak_ptr &&other) noexcept
 Move constructor. More...
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
 cycle_weak_ptr (const cycle_weak_ptr< U > &other) noexcept
 Copy constructor.
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
 cycle_weak_ptr (cycle_weak_ptr< U > &&other) noexcept
 Move constructor. More...
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
 cycle_weak_ptr (const cycle_gptr< U > &other) noexcept
 Create weak pointer from other. More...
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
 cycle_weak_ptr (const cycle_member_ptr< U > &other) noexcept
 Create weak pointer from other. More...
 
auto operator= (const cycle_weak_ptr &other) noexcept -> cycle_weak_ptr &
 Copy assignment.
 
auto operator= (cycle_weak_ptr &&other) noexcept -> cycle_weak_ptr &
 Move assignment. More...
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
auto operator= (const cycle_weak_ptr< U > &other) noexcept -> cycle_weak_ptr &
 Copy assignment.
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
auto operator= (cycle_weak_ptr< U > &&other) noexcept -> cycle_weak_ptr &
 Move assignment. More...
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
auto operator= (const cycle_gptr< U > &other) noexcept -> cycle_weak_ptr &
 Assign other. post this->lock() == other.
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
auto operator= (const cycle_member_ptr< U > &other) noexcept -> cycle_weak_ptr &
 Assign other. post this->lock() == other.
 
auto reset () noexcept -> void
 Reset this pointer. More...
 
auto swap (cycle_weak_ptr &other) noexcept -> void
 Swap with another weak pointer.
 
auto expired () const noexcept -> bool
 Test if this weak pointer is expired. More...
 
auto lock () const noexcept -> cycle_gptr< T >
 Retrieve cycle_gptr from this. More...
 
template<typename U >
auto owner_before (const cycle_weak_ptr< U > &other) const noexcept -> bool
 Ownership ordering. More...
 
template<typename U >
auto owner_before (const cycle_gptr< U > &other) const noexcept -> bool
 Ownership ordering. More...
 
template<typename U >
auto owner_before (const cycle_member_ptr< U > &other) const noexcept -> bool
 Ownership ordering. More...
 

Friends

template<typename >
class cycle_member_ptr
 
template<typename >
class cycle_gptr
 
template<typename >
class cycle_weak_ptr
 

Related Functions

(Note that these are not member functions.)

template<typename T >
auto swap (cycle_weak_ptr< T > &x, cycle_weak_ptr< T > &y) noexcept -> void
 Swap two pointers. More...
 

Detailed Description

template<typename T>
class cycle_ptr::cycle_weak_ptr< T >

Weak cycle pointer.

A weak pointer does not have ownership of its target, depending on cycle_member_ptr and cycle_gptr keeping its target reachable.

Member Typedef Documentation

◆ element_type

template<typename T>
using cycle_ptr::cycle_weak_ptr< T >::element_type = std::remove_extent_t<T>

Element type of this pointer.

Constructor & Destructor Documentation

◆ cycle_weak_ptr() [1/4]

template<typename T>
cycle_ptr::cycle_weak_ptr< T >::cycle_weak_ptr ( cycle_weak_ptr< T > &&  other)
inlinenoexcept

Move constructor.

Postcondition
other.lock() == nullptr

◆ cycle_weak_ptr() [2/4]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
cycle_ptr::cycle_weak_ptr< T >::cycle_weak_ptr ( cycle_weak_ptr< U > &&  other)
inlinenoexcept

Move constructor.

Postcondition
other.lock() == nullptr

◆ cycle_weak_ptr() [3/4]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
cycle_ptr::cycle_weak_ptr< T >::cycle_weak_ptr ( const cycle_gptr< U > &  other)
inlinenoexcept

Create weak pointer from other.

Postcondition
this->lock() == other

◆ cycle_weak_ptr() [4/4]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
cycle_ptr::cycle_weak_ptr< T >::cycle_weak_ptr ( const cycle_member_ptr< U > &  other)
inlinenoexcept

Create weak pointer from other.

Postcondition
this->lock() == other

Member Function Documentation

◆ expired()

template<typename T>
auto cycle_ptr::cycle_weak_ptr< T >::expired ( ) const -> bool
inlinenoexcept

Test if this weak pointer is expired.

Returns
True if this weak pointer is expired, meaning that its pointee has been collected.

◆ lock()

template<typename T>
auto cycle_ptr::cycle_weak_ptr< T >::lock ( ) const -> cycle_gptr<T>
inlinenoexcept

Retrieve cycle_gptr from this.

Unlike cycle_gptr<T>(*this), this method does not throw an exception.

Returns
cycle_gptr holding the value of this, or nullptr if this is expired.

◆ operator=() [1/2]

template<typename T>
auto cycle_ptr::cycle_weak_ptr< T >::operator= ( cycle_weak_ptr< T > &&  other) -> cycle_weak_ptr&
inlinenoexcept

Move assignment.

Postcondition
other.lock() == nullptr

◆ operator=() [2/2]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T*>>>
auto cycle_ptr::cycle_weak_ptr< T >::operator= ( cycle_weak_ptr< U > &&  other) -> cycle_weak_ptr&
inlinenoexcept

Move assignment.

Postcondition
other.lock() == nullptr

◆ owner_before() [1/3]

template<typename T>
template<typename U >
auto cycle_ptr::cycle_weak_ptr< T >::owner_before ( const cycle_weak_ptr< U > &  other) const -> bool
inlinenoexcept

Ownership ordering.

◆ owner_before() [2/3]

template<typename T>
template<typename U >
auto cycle_ptr::cycle_weak_ptr< T >::owner_before ( const cycle_gptr< U > &  other) const -> bool
inlinenoexcept

Ownership ordering.

◆ owner_before() [3/3]

template<typename T>
template<typename U >
auto cycle_ptr::cycle_weak_ptr< T >::owner_before ( const cycle_member_ptr< U > &  other) const -> bool
inlinenoexcept

Ownership ordering.

◆ reset()

template<typename T>
auto cycle_ptr::cycle_weak_ptr< T >::reset ( ) -> void
inlinenoexcept

Reset this pointer.

Postcondition
this->lock() == nullptr

Friends And Related Function Documentation

◆ swap()

template<typename T >
auto swap ( cycle_weak_ptr< T > &  x,
cycle_weak_ptr< T > &  y 
) -> void
related

Swap two pointers.


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