Value typically wrapping function call result and success indicator. More...
#include <eagine/extract.hpp>
Public Member Functions | |
constexpr | ok (Outcome &&outcome) noexcept(noexcept(std::declval< Outcome && >())) |
Construction from a function call outcome object. | |
constexpr | operator bool () noexcept(noexcept(bool(std::declval< Outcome & >()))) |
Indicates if the stored outcome contains valid result value. | |
constexpr | operator bool () const noexcept(noexcept(bool(std::declval< const Outcome & >()))) |
Indicates if the stored outcome contains valid result value. | |
constexpr auto | get () noexcept(noexcept(extract(_outcome))) -> decltype(extract(_outcome)) |
Extracts the stored outcome value. More... | |
constexpr auto | get () const noexcept(noexcept(extract(_outcome))) -> decltype(extract(_outcome)) |
Extracts the stored outcome value. More... | |
constexpr | operator decltype (extract(std::declval< Outcome & >()))() noexcept(noexcept(extract(_outcome))) |
Implicit conversion to the stored outcome value. More... | |
constexpr | operator decltype (extract(std::declval< const Outcome & >()))() const noexcept(noexcept(extract(_outcome))) |
Implicit conversion to the stored outcome value. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Outcome > | |
auto | extract (const ok< Outcome > &x) noexcept -> const auto & |
Overload of extract for instantiations of the ok template. | |
template<typename Outcome > | |
auto | begin (const ok< Outcome > &x, decltype(std::declval< const ok< Outcome > & >().get().begin()) *=nullptr) |
Overload of begin for instantiations of the ok template. | |
template<typename Outcome > | |
auto | end (const ok< Outcome > &x, decltype(std::declval< const ok< Outcome > & >().get().end()) *=nullptr) |
Overload of begin for instantiations of the ok template. | |
Value typically wrapping function call result and success indicator.
Outcome | the actual function call result type. |
Instances of this class are used to store the result of a function call and store the actual result together with some ingication whether the call was actually successful. This means that the stored result value is only optionally valid as indicated by the conversion-to-boolean operator.
The ok class can, depending on specializations of ok_traits, provide additional information about why the associated function call failed, for example an error code or error message string, etc.
This class is typically used to store and retrieve C-API function call results where the success is indicated by errno
or some such global variable.
|
inlineconstexprnoexcept |
Extracts the stored outcome value.
|
inlineconstexprnoexcept |
Extracts the stored outcome value.
|
inlineconstexprnoexcept |
Implicit conversion to the stored outcome value.
|
inlineconstexprnoexcept |
Implicit conversion to the stored outcome value.