VCV Rack API v2
Loading...
Searching...
No Matches
rack::WeakPtr< T > Struct Template Reference

A weak pointer to a subclass of WeakBase. More...

#include <weakptr.hpp>

Collaboration diagram for rack::WeakPtr< T >:
[legend]

Public Member Functions

 WeakPtr ()
 
 WeakPtr (T *ptr)
 
 WeakPtr (const WeakPtr &other)
 
WeakPtroperator= (const WeakPtr &other)
 
 ~WeakPtr ()
 
void set (T *ptr)
 
T * get () const
 
T * operator-> () const
 
T & operator* () const
 
 operator T* () const
 
 operator bool () const
 

Public Attributes

WeakHandleweakHandle = NULL
 

Detailed Description

template<typename T>
struct rack::WeakPtr< T >

A weak pointer to a subclass of WeakBase.

Weak pointers behave like raw pointers but can be accessed safely (returning nullptr) after the pointed object is deleted.

Example:

Foo* foo = new Foo;
WeakPtr<Foo> weakFoo = foo;
weakFoo.get(); // returns foo
delete foo;
weakFoo.get(); // returns nullptr

Not thread safe. In multithreaded environments, the object pointed to by the WeakPtr could be deleted at any time after obtaining its pointer from WeakPtr.

Constructor & Destructor Documentation

◆ WeakPtr() [1/3]

template<typename T >
rack::WeakPtr< T >::WeakPtr ( )
inline

◆ WeakPtr() [2/3]

template<typename T >
rack::WeakPtr< T >::WeakPtr ( T * ptr)
inline

◆ WeakPtr() [3/3]

template<typename T >
rack::WeakPtr< T >::WeakPtr ( const WeakPtr< T > & other)
inline

◆ ~WeakPtr()

template<typename T >
rack::WeakPtr< T >::~WeakPtr ( )
inline

Member Function Documentation

◆ operator=()

template<typename T >
WeakPtr & rack::WeakPtr< T >::operator= ( const WeakPtr< T > & other)
inline

◆ set()

template<typename T >
void rack::WeakPtr< T >::set ( T * ptr)
inline

◆ get()

template<typename T >
T * rack::WeakPtr< T >::get ( ) const
inline

◆ operator->()

template<typename T >
T * rack::WeakPtr< T >::operator-> ( ) const
inline

◆ operator*()

template<typename T >
T & rack::WeakPtr< T >::operator* ( ) const
inline

◆ operator T*()

template<typename T >
rack::WeakPtr< T >::operator T* ( ) const
inline

◆ operator bool()

template<typename T >
rack::WeakPtr< T >::operator bool ( ) const
inlineexplicit

Member Data Documentation

◆ weakHandle

template<typename T >
WeakHandle* rack::WeakPtr< T >::weakHandle = NULL

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