Class endstone::NotNull¶
ClassList > endstone > NotNull
A wrapper around a std::shared_ptr that documents that it is never 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 (const Nullable< T > & other) Narrowing conversion from a Nullable . |
|
| NotNull (std::nullptr_t) = delete |
|
| Nullable< U > | as () const Attempts to narrow the pointee to the given type U, keeping the shared ownership. |
| NotNull< U > | cast () const |
| const pointer_type & | get () noexcept const |
| bool | is () const Checks if the pointee is an instance of the given type U (or a subclass of U). |
| 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¶
This carries the same weight as Java's @ NotNull: it states the contract and costs nothing at run time. Passing nullptr is a compile error, as are the pointer-mutating operators, but a null shared_ptr handed over at run time is not diagnosed. Validate at the boundary where the pointer enters the API, not here.
Public Types Documentation¶
typedef element_type¶
typedef pointer_type¶
Public Functions Documentation¶
function NotNull [1/7]¶
function NotNull [2/7]¶
function NotNull [3/7]¶
function NotNull [4/7]¶
Covariant conversion from a shared_ptr of a convertible (e.g.
derived) type.
function NotNull [5/7]¶
Covariant conversion from a NotNull of a convertible (e.g.
derived) type.
function NotNull [6/7]¶
Narrowing conversion from a Nullable .
function NotNull [7/7]¶
function as¶
Attempts to narrow the pointee to the given type U, keeping the shared ownership.
Returns a null Nullable if the pointee is not an instance of U (or a subclass of U).
Template parameters:
UTarget type to narrow to (must derive from Object)
Returns:
A Nullable holding this as U, or a null Nullable if the narrowing is invalid
function cast¶
function get¶
function is¶
Checks if the pointee is an instance of the given type U (or a subclass of U).
Template parameters:
UType to check against (must derive from Object)
Returns:
true if the pointee is an instance of U
function operator*¶
function operator++¶
function operator++¶
function operator+=¶
function operator--¶
function operator--¶
function operator-=¶
function operator->¶
function operator=¶
function operator=¶
function operator[]¶
function swap¶
The documentation for this class was generated from the following file include/endstone/util/pointers.h