std::optional
usefull methods.
More...
#include <optional.hpp>
Public Member Functions | |
constexpr | Optional () noexcept |
constexpr | Optional (std::nullopt_t null) noexcept |
constexpr | Optional (const std::optional< T > &other) |
constexpr | Optional (std::optional< T > &&other) noexcept |
template<typename U> | |
Optional (const std::optional< U > &other) | |
template<typename U> | |
Optional (std::optional< U > &&other) | |
template<typename... Args> | |
constexpr | Optional (std::in_place_t inplace, Args &&... args) |
template<typename U, typename... Args> | |
constexpr | Optional (std::in_place_t inplace, std::initializer_list< U > ilist, Args &&... args) |
template<typename U = T> | |
constexpr | Optional (U &&value) |
virtual | ~Optional () |
void | ifValue (std::function< void(const T &)> func) |
void | ifValueOrElse (std::function< void(const T &)> func, std::function< void()> fallback) |
template<typename U> | |
Optional< U > | map (std::function< U(const T &)> mapper) const |
std::optional
usefull methods.
Provides some missing (from my point of view) features to std::optional
.
|
constexprnoexcept |
Optional default constructor
|
constexprnoexcept |
Optional constructor
null | the NULL value |
|
constexpr |
Optional 'copy' construtor
other | the std::optional to copy |
|
constexprnoexcept |
Optional 'move' constructor
other | the std::optional to move |
anch::Optional< T >::Optional | ( | const std::optional< U > & | other | ) |
Optional converting 'copy' construtor
other | the std::optional to copy |
anch::Optional< T >::Optional | ( | std::optional< U > && | other | ) |
Optional converting 'move' constructor
other | the std::optional to move |
|
explicitconstexpr |
Optional constructor.
This constructor will initialize containing object with args.
inplace | parameters to force T construction |
args | the T type constructor arguments |
|
explicitconstexpr |
Optional constructor.
This constructor will initialize containing object with args.
inplace | parameters to force T construction |
ilist | the std::list initializer |
args | the T type constructor arguments |
Optional constructor.
value | the value to convert |
|
virtual |
Optional destructor
|
inline |
Apply treatment if optional has value
func | the treatment to apply when optional has value |
|
inline |
Apply treatment if optional has value or apply fallback treatment
func | the treatment to apply when optional has value |
fallback | the treatment to apply when optional has no value |
|
inline |
Transform optional type to another.
It value is not set, return an empty optional.
mapper | the mapping function |