OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::ok< Outcome > Class Template Reference

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.
 

Detailed Description

template<typename Outcome>
class eagine::ok< Outcome >

Value typically wrapping function call result and success indicator.

Template Parameters
Outcomethe actual function call result type.
See also
ok_traits
valid_if

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.

Examples
eglplus/001_basic_info.cpp, eglplus/003_list_extensions.cpp, eglplus/005_list_configs.cpp, eglplus/006_multisample_configs.cpp, eglplus/007_depth_stencil_configs.cpp, eglplus/008_list_extensions.cpp, oalplus/005_hello_world.cpp, and oglplus/001_glfw3_glew_info.cpp.

Member Function Documentation

◆ get() [1/2]

template<typename Outcome >
constexpr auto eagine::ok< Outcome >::get ( ) const -> decltype(extract(_outcome))
inlineconstexprnoexcept

Extracts the stored outcome value.

Precondition
bool(*this)

◆ get() [2/2]

template<typename Outcome >
constexpr auto eagine::ok< Outcome >::get ( ) -> decltype(extract(_outcome))
inlineconstexprnoexcept

Extracts the stored outcome value.

Precondition
bool(*this)

◆ operator decltype() [1/2]

template<typename Outcome >
constexpr eagine::ok< Outcome >::operator decltype ( extract(std::declval< const Outcome & >())  ) const
inlineconstexprnoexcept

Implicit conversion to the stored outcome value.

Precondition
bool(*this)

◆ operator decltype() [2/2]

template<typename Outcome >
constexpr eagine::ok< Outcome >::operator decltype ( extract(std::declval< Outcome & >())  )
inlineconstexprnoexcept

Implicit conversion to the stored outcome value.

Precondition
bool(*this)

The documentation for this class was generated from the following file:

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).