Struct representing the return type of a function performing an operation that may fail. Contains a discriminated union of either a success type (specified by T), or an Error state. Allows monadic manipulation of return values from functions using this struct, allowing callers to early return, or take an alternate value, in the case of an error.
More...
#include <PureResult.h>
|
bool | IsError () const |
|
void | IgnoreResult () const |
| Suppress possible errors in this Result.
|
|
| ValueResult (T &&entity) |
|
| ValueResult (ValueResult const &other)=delete |
|
| ValueResult (ValueResult &&other) noexcept |
|
| ValueResult (ErrorStruct &&error) noexcept |
|
ValueResult & | operator= (ValueResult const &other)=delete |
|
ValueResult & | operator= (ValueResult &&other) noexcept |
|
ValueResult< std::monostate > | DiscardValue () |
| Converts a ValueResult into a PureResult by dropping any value it held.
|
|
ErrorStruct const & | Error () const |
|
ErrorStruct && | Error () |
|
void | HandleError () const |
| Marks ERROR struct has being handled, allowing the struct to safely leave scope without throwing the error.
|
|
T const & | Get () const |
| Get the value held by this result. Callers must validate struct contains OK result before calling. More...
|
|
T && | Take () |
| Get the value held by this result. Callers must validate struct contains OK result before calling. More...
|
|
auto & | GetAndUnwrapReference () |
| Get the unwrapped value held by this result when the value is of type std::reference_wrapper. More...
|
|
T const & | GetOrDefault (T const &defaultValue) const |
|
T && | TakeOrDefault (T &&defaultValue) |
|
|
static ValueResult | OK (T &&entity) |
| Factory method creating a ValueResult in the OK state, holding the provided value.
|
|
static ValueResult< std::monostate > | OK () |
| Factory method creating a PureResult (ValueResult<std::monostate>) in the OK state.
|
|
static ValueResult | Error (std::string errorMessage) |
| Factory method creating a Result in the Error state.
|
|
static ValueResult | Error (std::string const error, std::exception const &exception) |
| Factory method creating a Result in the Error state.
|
|
template<class T>
struct AnimationSystem::ValueResult< T >
Struct representing the return type of a function performing an operation that may fail. Contains a discriminated union of either a success type (specified by T), or an Error state. Allows monadic manipulation of return values from functions using this struct, allowing callers to early return, or take an alternate value, in the case of an error.
- Template Parameters
-
T | Return type. If none is desired use PureResult typedef which templated this class with std::monostate. |
◆ Error() [1/2]
- Returns
- The error in this Result. Calling this on a Result that is OK is forbidden
◆ Error() [2/2]
- Returns
- The error in this Result. Calling this on a Result that is OK is forbidden
◆ Get()
Get the value held by this result. Callers must validate struct contains OK result before calling.
- Returns
- Gets const ref of result from struct
◆ GetAndUnwrapReference()
Get the unwrapped value held by this result when the value is of type std::reference_wrapper.
- Returns
- Gets const ref of the result of std::reference_wrapper.get() called on the value of this struct
◆ GetOrDefault()
- Returns
- Const ref to result if struct is OK, or returns parameter provided
◆ IsError()
- Returns
- If this struct is ERROR, regardless of if the error is handled
◆ Take()
Get the value held by this result. Callers must validate struct contains OK result before calling.
- Returns
- Moves result out of struct
◆ TakeOrDefault()
- Returns
- Moves result out of struct if struct is OK, or returns parameter provided
The documentation for this struct was generated from the following file:
- C:/Users/Jay Bretherton/Documents/GitHub/418/Projects/animated_mesh/build/vs2017/AnimationSystem/PureResult.h