Skip to content

Class endstone::NotNull

template <class T>

ClassList > endstone > NotNull

A wrapper around a std::shared_ptr that is guaranteed never to be null. More...

  • #include <endstone/util/pointers.h>

Public Types

Type Name
typedef T element_type
typedef std::shared_ptr< T > pointer_type

Public Functions

Type Name
NotNull () = delete
NotNull (std::shared_ptr< T > ptr)
NotNull (const NotNull & other) = default
NotNull (std::shared_ptr< U > ptr)
Covariant conversion from a shared_ptr of a convertible (e.g.
NotNull (const NotNull< U > & other)
Covariant conversion from a NotNull of a convertible (e.g.
NotNull (std::nullptr_t) = delete
const pointer_type & get () noexcept const
T & operator* () noexcept const
NotNull & operator++ () = delete
NotNull operator++ (int) = delete
NotNull & operator+= (std::ptrdiff_t) = delete
NotNull & operator-- () = delete
NotNull operator-- (int) = delete
NotNull & operator-= (std::ptrdiff_t) = delete
T * operator-> () noexcept const
NotNull & operator= (const NotNull & other) = default
NotNull & operator= (std::nullptr_t) = delete
void operator[] (std::ptrdiff_t) const
void swap (NotNull & other) noexcept

Detailed Description

Construction from a null pointer throws, and the pointer-mutating operators are deleted. This mirrors gsl::not_null<std::shared_ptr<T>>, but throws std::invalid_argument on a null pointer (instead of a contract violation) so that a misbehaving plugin cannot crash the host.

Public Types Documentation

typedef element_type

using endstone::NotNull< T >::element_type =  T;

typedef pointer_type

using endstone::NotNull< T >::pointer_type =  std::shared_ptr<T>;

Public Functions Documentation

function NotNull [⅙]

endstone::NotNull::NotNull () = delete

function NotNull [2/6]

inline endstone::NotNull::NotNull (
    std::shared_ptr< T > ptr
) 

function NotNull [3/6]

endstone::NotNull::NotNull (
    const  NotNull & other
) = default

function NotNull [4/6]

Covariant conversion from a shared_ptr of a convertible (e.g.

template<class  U>
inline endstone::NotNull::NotNull (
    std::shared_ptr< U > ptr
) 

derived) type.


function NotNull [⅚]

Covariant conversion from a NotNull of a convertible (e.g.

template<class  U>
inline endstone::NotNull::NotNull (
    const  NotNull < U > & other
) 

derived) type.


function NotNull [6/6]

endstone::NotNull::NotNull (
    std::nullptr_t
) = delete

function get

inline const pointer_type & endstone::NotNull::get () noexcept const

function operator*

inline T & endstone::NotNull::operator* () noexcept const

function operator++

NotNull & endstone::NotNull::operator++ () = delete

function operator++

NotNull endstone::NotNull::operator++ (
    int
) = delete

function operator+=

NotNull & endstone::NotNull::operator+= (
    std::ptrdiff_t
) = delete

function operator--

NotNull & endstone::NotNull::operator-- () = delete

function operator--

NotNull endstone::NotNull::operator-- (
    int
) = delete

function operator-=

NotNull & endstone::NotNull::operator-= (
    std::ptrdiff_t
) = delete

function operator->

inline T * endstone::NotNull::operator-> () noexcept const

function operator=

NotNull & endstone::NotNull::operator= (
    const  NotNull & other
) = default

function operator=

NotNull & endstone::NotNull::operator= (
    std::nullptr_t
) = delete

function operator[]

void endstone::NotNull::operator[] (
    std::ptrdiff_t
) const

function swap

inline void endstone::NotNull::swap (
    NotNull & other
) noexcept


The documentation for this class was generated from the following file include/endstone/util/pointers.h