Seastar
High performance C++ framework for concurrent servers
|
seastar::checked_ptr class is a wrapper class that may be used with any pointer type (smart like std::unique_ptr or raw pointers like int*).
The seastar::checked_ptr object will invoke the NullDerefAction functor if it is dereferenced when the underlying pointer is not engaged.
It may still be assigned, compared to other seastar::checked_ptr objects or moved without limitations.
The default NullDerefAction will throw a seastar::default_null_deref_action exception.
NullDerefAction | a functor that is invoked when a user tries to dereference a not engaged pointer. |
#include <seastar/core/checked_ptr.hh>
Public Types | |
using | element_type = typename std::pointer_traits< Ptr >::element_type |
Underlying element type. | |
using | pointer = element_type * |
Type of the pointer to the underlying element. | |
Public Member Functions | |
checked_ptr (std::nullptr_t) noexcept(std::is_nothrow_default_constructible_v< checked_ptr< Ptr, NullDerefAction > >) | |
checked_ptr (Ptr &&ptr) noexcept(std::is_nothrow_move_constructible_v< Ptr >) | |
checked_ptr (const Ptr &p) noexcept(std::is_nothrow_copy_constructible_v< Ptr >) | |
Checked Methods | |
These methods start with invoking a NullDerefAction functor if the underlying pointer is not engaged. | |
pointer | get () const |
const Ptr & | operator-> () const |
Ptr & | operator-> () |
const element_type & | operator* () const |
element_type & | operator* () |
Unchecked methods | |
These methods may be invoked when the underlying pointer is not engaged. | |
operator bool () const | |
bool | operator== (const checked_ptr &other) const |
bool | operator!= (const checked_ptr &other) const |
size_t | hash () const |
|
inline |
Invokes the get() method of the underlying smart pointer or returns the pointer itself for a raw pointer (const variant).
|
inline |
Gets the hash value for the underlying pointer object.
|
inlineexplicit |
Checks if the underlying pointer is engaged.
|
inline |
Gets the reference to the underlying object.
|
inline |
Gets the reference to the underlying object (const variant).
|
inline |
Gets a reference to the underlying pointer object (const variant).
|
inline |
Gets a reference to the underlying pointer object.