Celeritas  0.5.0-56+6b053cd
List of all members
celeritas::ObserverPtr< T, M > Class Template Reference

Type-safe non-owning pointer. More...

#include <ObserverPtr.hh>

Public Member Functions

CELER_CONSTEXPR_FUNCTION pointer get () const noexcept
 
CELER_CONSTEXPR_FUNCTION reference operator* () const noexcept
 
CELER_CONSTEXPR_FUNCTION pointer operator-> () const noexcept
 
CELER_CONSTEXPR_FUNCTION operator pointer () const noexcept
 
CELER_CONSTEXPR_FUNCTION operator bool () const noexcept
 
CELER_CONSTEXPR_FUNCTION pointer release () noexcept
 
CELER_CONSTEXPR_FUNCTION void reset (pointer ptr=nullptr) noexcept
 
CELER_CONSTEXPR_FUNCTION void swap (ObserverPtr &other) noexcept
 

Type aliases

using element_type = T
 
using pointer = std::add_pointer_t< T >
 
using reference = std::add_lvalue_reference_t< T >
 
constexpr ObserverPtr () noexcept=default
 
CELER_CONSTEXPR_FUNCTION ObserverPtr (std::nullptr_t) noexcept
 
CELER_CONSTEXPR_FUNCTION ObserverPtr (pointer ptr) noexcept
 
template<class T2 >
CELER_CONSTEXPR_FUNCTION ObserverPtr (ObserverPtr< T2, M > other) noexcept
 

Detailed Description

template<class T, MemSpace M = MemSpace::native>
class celeritas::ObserverPtr< T, M >

Type-safe non-owning pointer.

This class is based on WG21 N4282, "A Proposal for the World’s Dumbest Smart Pointer, v4". It adds memspace safety similar to Thrust's host/device_ptr.

The dereferencing operators can only be used from the "native" memspace: i.e., host data can be accessed from a .cc file, and device data from a .cu file.

A manual pointer cast function can be used to access the pointer with no memspace checking.

Member Typedef Documentation

◆ element_type

template<class T , MemSpace M = MemSpace::native>
using celeritas::ObserverPtr< T, M >::element_type = T

Construct a pointer

◆ pointer

template<class T , MemSpace M = MemSpace::native>
using celeritas::ObserverPtr< T, M >::pointer = std::add_pointer_t<T>

Construct a pointer

◆ reference

template<class T , MemSpace M = MemSpace::native>
using celeritas::ObserverPtr< T, M >::reference = std::add_lvalue_reference_t<T>

Construct a pointer

Constructor & Destructor Documentation

◆ ObserverPtr() [1/4]

template<class T , MemSpace M = MemSpace::native>
constexpr celeritas::ObserverPtr< T, M >::ObserverPtr ( )
constexprdefaultnoexcept

Construct a pointer

◆ ObserverPtr() [2/4]

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION celeritas::ObserverPtr< T, M >::ObserverPtr ( std::nullptr_t  )
inlinenoexcept

Construct a pointer

◆ ObserverPtr() [3/4]

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION celeritas::ObserverPtr< T, M >::ObserverPtr ( pointer  ptr)
inlineexplicitnoexcept

Construct a pointer

◆ ObserverPtr() [4/4]

template<class T , MemSpace M = MemSpace::native>
template<class T2 >
CELER_CONSTEXPR_FUNCTION celeritas::ObserverPtr< T, M >::ObserverPtr ( ObserverPtr< T2, M >  other)
inlinenoexcept

Construct a pointer

Member Function Documentation

◆ get()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION pointer celeritas::ObserverPtr< T, M >::get ( ) const
inlinenoexcept

Access the pointer

◆ operator bool()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION celeritas::ObserverPtr< T, M >::operator bool ( ) const
inlineexplicitnoexcept

Access the pointer

◆ operator pointer()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION celeritas::ObserverPtr< T, M >::operator pointer ( ) const
inlineexplicitnoexcept

Access the pointer

◆ operator*()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION reference celeritas::ObserverPtr< T, M >::operator* ( ) const
inlinenoexcept

Access the pointer

◆ operator->()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION pointer celeritas::ObserverPtr< T, M >::operator-> ( ) const
inlinenoexcept

Access the pointer

◆ release()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION pointer celeritas::ObserverPtr< T, M >::release ( )
inlinenoexcept

Modify the pointer

◆ reset()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION void celeritas::ObserverPtr< T, M >::reset ( pointer  ptr = nullptr)
inlinenoexcept

Modify the pointer

◆ swap()

template<class T , MemSpace M = MemSpace::native>
CELER_CONSTEXPR_FUNCTION void celeritas::ObserverPtr< T, M >::swap ( ObserverPtr< T, M > &  other)
inlinenoexcept

Modify the pointer


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