A nullable smart wrapper around a raw pointer. More...
#include <mxvk/include/mxvk/mxvk_wrapper.hpp>
Public Member Functions | |
| T | expect (const std::string &msg) const |
| Unwrap with a custom panic message on null. | |
| bool | has_value () const noexcept |
| Check whether a non-null value is held. | |
| operator bool () const noexcept | |
| Check if a value is present and non-null. | |
| Wrapper< T > & | operator= (const Wrapper< T > &)=default |
| Copy-assign from another Wrapper. | |
| Wrapper< T > & | operator= (std::nullopt_t nullopt) |
| Reset to the empty (nullopt) state. | |
| Wrapper< T > & | operator= (T t) |
| Assign from a raw pointer. | |
| Wrapper< T > & | operator= (Wrapper< T > &&) noexcept=default |
| Move-assign from another Wrapper. | |
| T | unwrap () const |
| Unwrap the stored pointer, panicking on null. | |
| T | unwrap_or (T fallback) const noexcept |
| Return the stored pointer or a fallback if null. | |
| T | value () const |
| Access the stored pointer without null checking. | |
| Wrapper ()=default | |
| Default constructor — initialises to nullopt (no value). | |
| Wrapper (const Wrapper< T > &)=default | |
| Copy constructor. | |
| Wrapper (std::nullopt_t nullopt) | |
| Construct in the empty (nullopt) state. | |
| Wrapper (T t) | |
| Construct from a raw pointer. | |
| Wrapper (Wrapper< T > &&) noexcept=default | |
| Move constructor. | |
| ~Wrapper ()=default | |
A nullable smart wrapper around a raw pointer.
Stores an optional pointer. Accessors throw mx::Exception if the pointer is null (unwrap, expect) or return a fallback (unwrap_or).
| T | A raw pointer type (must satisfy WrapType concept). |
Definition at line 37 of file mxvk_wrapper.hpp.
|
default |
Default constructor — initialises to nullopt (no value).
|
inline |
Construct from a raw pointer.
| t | Pointer to wrap. |
Definition at line 46 of file mxvk_wrapper.hpp.
|
inline |
Construct in the empty (nullopt) state.
| nullopt | std::nullopt. |
Definition at line 52 of file mxvk_wrapper.hpp.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
default |
|
inlinenodiscard |
Unwrap with a custom panic message on null.
| msg | Message to include in the thrown mx::Exception. |
| mx::Exception | if the value is null or absent. |
Definition at line 111 of file mxvk_wrapper.hpp.
|
inlinenodiscardnoexcept |
Check whether a non-null value is held.
true if a non-null pointer is stored. Definition at line 92 of file mxvk_wrapper.hpp.
|
inlineexplicitnodiscardnoexcept |
|
default |
Copy-assign from another Wrapper.
|
inline |
Reset to the empty (nullopt) state.
| nullopt | std::nullopt. |
Definition at line 77 of file mxvk_wrapper.hpp.
|
inline |
Assign from a raw pointer.
| t | Pointer to store. |
Definition at line 67 of file mxvk_wrapper.hpp.
|
defaultnoexcept |
Move-assign from another Wrapper.
|
inlinenodiscard |
Unwrap the stored pointer, panicking on null.
| mx::Exception | if the value is null or absent. |
Definition at line 123 of file mxvk_wrapper.hpp.
|
inlinenodiscardnoexcept |
Return the stored pointer or a fallback if null.
| fallback | Pointer returned when no value is held. |
fallback if null/absent. Definition at line 135 of file mxvk_wrapper.hpp.
|
inlinenodiscard |
Access the stored pointer without null checking.
Definition at line 103 of file mxvk_wrapper.hpp.