SPH
Public Member Functions | List of all members
RawPtr< T > Class Template Reference

Non-owning wrapper of pointer. More...

#include <RawPtr.h>

Public Member Functions

INLINE RawPtr ()
 
INLINE RawPtr (std::nullptr_t)
 
template<typename T2 , typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
INLINE RawPtr (T2 *ptr)
 
INLINE RawPtroperator= (std::nullptr_t)
 
template<typename T2 , typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
INLINE RawPtroperator= (T2 *rhs)
 
INLINE T & operator* () const
 
INLINE T * operator-> () const
 
INLINE operator bool () const
 
INLINE bool operator! () const
 
 operator RawPtr< const T > () const
 
INLINE T * get () const
 
INLINE void swap (RawPtr &other)
 

Detailed Description

template<typename T>
class RawPtr< T >

Non-owning wrapper of pointer.

Inspired by proposal of std::observer_ptr. It mainly serves for self-documentation, clearly expressing ownership (or non-ownership in this case) of the pointer. Unlike raw pointer, it is initialized to nullptr for convenience. This is a slight overhead compared to raw pointer, negligible in most use cases. When deferencing the pointer, it checks for nullptr using assert.

Definition at line 19 of file RawPtr.h.

Constructor & Destructor Documentation

◆ RawPtr() [1/3]

template<typename T >
INLINE RawPtr< T >::RawPtr ( )
inline

Definition at line 24 of file RawPtr.h.

◆ RawPtr() [2/3]

template<typename T >
INLINE RawPtr< T >::RawPtr ( std::nullptr_t  )
inline

Definition at line 27 of file RawPtr.h.

◆ RawPtr() [3/3]

template<typename T >
template<typename T2 , typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
INLINE RawPtr< T >::RawPtr ( T2 *  ptr)
inline

Definition at line 31 of file RawPtr.h.

Member Function Documentation

◆ get()

template<typename T >
INLINE T* RawPtr< T >::get ( ) const
inline

Definition at line 67 of file RawPtr.h.

◆ operator bool()

template<typename T >
INLINE RawPtr< T >::operator bool ( ) const
inlineexplicit

Definition at line 55 of file RawPtr.h.

◆ operator RawPtr< const T >()

template<typename T >
RawPtr< T >::operator RawPtr< const T > ( ) const
inline

Definition at line 63 of file RawPtr.h.

◆ operator!()

template<typename T >
INLINE bool RawPtr< T >::operator! ( ) const
inline

Definition at line 59 of file RawPtr.h.

◆ operator*()

template<typename T >
INLINE T& RawPtr< T >::operator* ( ) const
inline

Definition at line 45 of file RawPtr.h.

◆ operator->()

template<typename T >
INLINE T* RawPtr< T >::operator-> ( ) const
inline

Definition at line 50 of file RawPtr.h.

◆ operator=() [1/2]

template<typename T >
INLINE RawPtr& RawPtr< T >::operator= ( std::nullptr_t  )
inline

Definition at line 34 of file RawPtr.h.

◆ operator=() [2/2]

template<typename T >
template<typename T2 , typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
INLINE RawPtr& RawPtr< T >::operator= ( T2 *  rhs)
inline

Definition at line 40 of file RawPtr.h.

◆ swap()

template<typename T >
INLINE void RawPtr< T >::swap ( RawPtr< T > &  other)
inline

Definition at line 71 of file RawPtr.h.


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