emlabcpp
modern opinionated embedded C++ library
emlabcpp::outcome Struct Reference

outcome represents tristate resut of some operation, which can succeed, fail or produce an error. More...

#include <outcome.h>

+ Inheritance diagram for emlabcpp::outcome:
+ Collaboration diagram for emlabcpp::outcome:

Public Member Functions

constexpr outcome (result const r) noexcept
 
constexpr outcome (result_e const r) noexcept
 
constexpr operator result () const noexcept
 
constexpr status (enum_type s) noexcept
 
constexpr status (status const &) noexcept=default
 
constexpr status (status &&) noexcept=default
 
- Public Member Functions inherited from emlabcpp::status< outcome, outcome_e >
constexpr status (enum_type s) noexcept
 
constexpr status (status const &) noexcept=default
 
constexpr status (status &&) noexcept=default
 
constexpr statusoperator= (status const &) noexcept=default
 
constexpr statusoperator= (status &&) noexcept=default
 
constexpr enum_type value () const noexcept
 

Additional Inherited Members

- Public Types inherited from emlabcpp::status< outcome, outcome_e >
using enum_type = outcome_e
 

Detailed Description

outcome represents tristate resut of some operation, which can succeed, fail or produce an error.

outcome is designed to be used with SUCCESS, FAILURE, and ERROR global constants. The common semantics should be:

  • SUCCESS - operation succeeded
  • FAILURE - operation failed, but only in way that can be expected and is not sign of a problem
  • ERROR - operaiton errored, in a way that is a sign of a problem For example, for parsing function, FAILURE should be used to mark that the parsed string is not valid, ERROR should be used to mark that unexpected internal error happend (out-of-bound access due to mistake in algorithm)

Supports comparison: outcome ot = ...; if(ot == outcome::SUCCESS) { ... }

Constructor & Destructor Documentation

◆ outcome() [1/2]

constexpr emlabcpp::outcome::outcome ( result const  r)
inlineconstexprnoexcept

◆ outcome() [2/2]

constexpr emlabcpp::outcome::outcome ( result_e const  r)
inlineconstexprnoexcept

Member Function Documentation

◆ operator result()

constexpr emlabcpp::outcome::operator result ( ) const
inlineconstexprnoexcept

References emlabcpp::SUCCESS.

◆ status() [1/3]

constexpr emlabcpp::status< Derived, Enum >::status
inlineconstexprnoexcept

◆ status() [2/3]

constexpr emlabcpp::status< Derived, Enum >::status
constexprdefaultnoexcept

◆ status() [3/3]

constexpr emlabcpp::status< Derived, Enum >::status
constexprdefaultnoexcept

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