Helper class storing both conditionally valid value and fallback. More...
#include <eagine/valid_if/decl.hpp>
Public Member Functions | |
valid_if_or_fallback (valid_if< T, P > vi, F fallback) noexcept(noexcept(valid_if< T, P >(std::declval< valid_if< T, P > && >())) &&noexcept(F(std::declval< F && >()))) | |
Constructor. | |
auto | fallback () const noexcept -> const F & |
Returns the stored fallback value. | |
auto | fallback () noexcept -> F & |
Returns the stored fallback value. | |
![]() | |
auto | operator= (const T &v) -> auto & |
Copies argument into this instance. | |
auto | operator= (T &&v) -> auto & |
Moves argument into this instance. | |
operator bool () const noexcept | |
Indicates if the stored value is valid according to policy. More... | |
auto | then (const Func &func) const -> std::enable_if_t< !std::is_same_v< std::result_of_t< Func(T)>, void >, valid_if< std::result_of_t< Func(T)>, valid_flag_policy >> |
Calls the specified function if the stored valus is valid. More... | |
auto | operator| (const Func &func) const |
Calls the specified function if the stored valus is valid. More... | |
auto | operator/ (const T &fallback) const noexcept -> const T & |
Returns the stored value if valid, returns fallback otherwise. More... | |
auto | operator* () const noexcept -> const T & |
Returns the stored value, throws if it is invalid. More... | |
auto | operator-> () const noexcept -> const T * |
Returns pointer to the stored value, throws if it is invalid. More... | |
constexpr auto | operator== (const T &v) const -> tribool |
Equality comparison of the stored value with v . | |
constexpr auto | operator!= (const T &v) const -> tribool |
Non-equality comparison of the stored value with v . | |
constexpr auto | operator< (const T &v) const -> tribool |
Less-than comparison of the stored value with v . | |
constexpr auto | operator> (const T &v) const -> tribool |
Greater-than comparison of the stored value with v . | |
constexpr auto | operator<= (const T &v) const -> tribool |
Less-equal comparison of the stored value with v . | |
constexpr auto | operator>= (const T &v) const -> tribool |
Greater-equal comparison of the stored value with v . | |
constexpr auto | is_valid (const T &val, P... p) const noexcept -> bool |
Checks if val is valid according to this object's policy. More... | |
constexpr auto | is_valid (P... p) const noexcept |
Checks if the stored value is valid according to policy. More... | |
auto | value (P... p) -> T & |
Returns the stored value if it is valid otherwise throws. More... | |
auto | value (P... p) const -> const T & |
Returns the stored value if it is valid, otherwise throws. More... | |
auto | value_or (T &fallback, P... p) noexcept -> auto & |
Returns the stored value if valid, otherwise returns fallback. More... | |
constexpr auto | value_or (const T &fallback, P... p) const noexcept -> auto & |
Returns the stored value if valid, otherwise returns fallback. More... | |
![]() | |
constexpr | basic_valid_if () noexcept |
Default constructor. | |
constexpr | basic_valid_if (T val) noexcept |
Constructor initializing the stored value by val . | |
constexpr | basic_valid_if (T val, P plcy) noexcept |
Constructor initializing the stored value and policy. | |
constexpr | basic_valid_if (const basic_valid_if &that) |
Copy constructor. | |
basic_valid_if (basic_valid_if &&that) noexcept(std::is_nothrow_move_constructible_v< T >) | |
Move constructor. | |
auto | policy () const noexcept -> const P & |
Returns a reference to this object's policy. | |
auto | operator= (const basic_valid_if &that) -> auto & |
Copy assignment operator. | |
auto | operator= (basic_valid_if &&that) noexcept(std::is_nothrow_move_assignable_v< T >) -> auto & |
Move assignment operator. | |
auto | operator= (const T &value) -> auto & |
Copies value into this instance. | |
~basic_valid_if () noexcept=default | |
The destructor. | |
constexpr auto | is_valid (const T &val, P... p) const noexcept -> bool |
Checks if val is valid according to this object's policy. More... | |
constexpr auto | is_valid (P... p) const noexcept |
Checks if the stored value is valid according to policy. More... | |
constexpr auto | has_value (P... p) const noexcept |
Checks if the stored value is valid according to policy. More... | |
auto | call_if_invalid (Func func, P... p) -> auto & |
Calls the specified function if the stored value is invalid. More... | |
void | throw_if_invalid (P... p) const |
Throws an exception if the stored value is invalid. More... | |
auto | value (P... p) -> T & |
Returns the stored value if it is valid otherwise throws. More... | |
auto | value (P... p) const -> const T & |
Returns the stored value if it is valid, otherwise throws. More... | |
auto | value_or (T &fallback, P... p) noexcept -> auto & |
Returns the stored value if valid, otherwise returns fallback. More... | |
constexpr auto | value_or (const T &fallback, P... p) const noexcept -> auto & |
Returns the stored value if valid, otherwise returns fallback. More... | |
constexpr auto | value_anyway (P...) const noexcept -> auto & |
Returns the stored value regardless of its validity. | |
constexpr auto | value_anyway (P...) noexcept -> auto & |
Returns the stored value regardless of its validity. | |
auto | then (const Func &func, P... p) const -> std::enable_if_t< std::is_same_v< std::result_of_t< Func(T)>, void >> |
Calls the specified function if the stored value is valid. More... | |
constexpr auto | transformed (Func func, P... p) const noexcept |
Calls a binary transforming function on {value, is_valid()} pair. More... | |
![]() | |
constexpr | basic_valid_if_value (T value) noexcept(noexcept(T(std::declval< T && >()))) |
Initializing constructor. | |
constexpr | basic_valid_if_value () noexcept(std::is_nothrow_default_constructible_v< T >)=default |
Default constructor. | |
constexpr | basic_valid_if_value (basic_valid_if_value &&) noexcept(std::is_nothrow_move_constructible_v< T >)=default |
Move constructor. | |
constexpr | basic_valid_if_value (const basic_valid_if_value &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default |
Copy constructor. | |
auto | operator= (basic_valid_if_value &&) noexcept(std::is_nothrow_move_assignable_v< T >) -> basic_valid_if_value &=default |
Move assignment operator. | |
auto | operator= (const basic_valid_if_value &) noexcept(std::is_nothrow_copy_assignable_v< T >) -> basic_valid_if_value &=default |
Copy assignment operator. | |
~basic_valid_if_value () noexcept=default | |
The destructor. | |
auto | operator= (const T &v) -> auto & |
Copies v to the stored value. | |
auto | operator= (T &&v) -> auto & |
Moves v to the stored value. | |
Helper class storing both conditionally valid value and fallback.