1#ifndef SDL3PP_OPTIONAL_REF_H_
2#define SDL3PP_OPTIONAL_REF_H_
40 constexpr bool has_value()
const {
return ptr !=
nullptr; }
43 constexpr const T&
value()
const {
return *ptr; }
46 constexpr T&
value() {
return *ptr; }
49 constexpr operator T*()
const {
return ptr; }
52 constexpr bool operator==(std::nullopt_t)
const {
return ptr ==
nullptr; }
58 constexpr const T&
operator*()
const {
return *ptr; }
73 if (ptr)
return {*ptr};
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
constexpr T & value()
Returns contained value.
Definition: SDL3pp_optionalRef.h:46
constexpr T & operator*()
Equivalent to value()
Definition: SDL3pp_optionalRef.h:55
constexpr auto operator<=>(const OptionalRef &) const =default
Constructor.
constexpr OptionalRef(T &value)
Constructor.
Definition: SDL3pp_optionalRef.h:31
constexpr T * operator->()
Equivalent to value()
Definition: SDL3pp_optionalRef.h:61
constexpr bool has_value() const
true if has a value.
Definition: SDL3pp_optionalRef.h:40
constexpr const T & value() const
Returns contained value.
Definition: SDL3pp_optionalRef.h:43
constexpr bool operator==(std::nullopt_t) const
Comparison operator.
Definition: SDL3pp_optionalRef.h:52
constexpr const T * operator->() const
Equivalent to value()
Definition: SDL3pp_optionalRef.h:64
constexpr OptionalRef(std::nullopt_t=std::nullopt)
Constructor.
Definition: SDL3pp_optionalRef.h:25
constexpr const T & operator*() const
Equivalent to value()
Definition: SDL3pp_optionalRef.h:58
Main include header for the SDL3pp library.
constexpr OptionalRef< T > fromNullable(T *ptr)
Create OptionalRef from a nullable pointer.
Definition: SDL3pp_optionalRef.h:71