|
template<typename T> |
Success< T > | mtcore::success (const T &v) |
| Creates a successful Result.
|
|
Success< void > | mtcore::success () |
| Creates a successful void Result object.
|
|
template<typename Underlying> |
Error< Underlying > | mtcore::error (Underlying err) |
| Creates an error.
|
|
template<typename Success, typename Acc, typename F, Iterable I, typename Err = typename decltype(std::declval<F>()( std::declval<std::remove_const_t<typename decltype(std::declval<I>().iter())::IterElem>>()))::Err> |
Result< Success, Err > | mtcore::results::accumulate (Success initial, const Acc &acc, const F &func, const I &iterable) |
| Chains together the execution of an errorable function on a list of arguments If an error is encountered, execution will stop and immediately return No Result value is returned Useful for performing side effects.
|
|
template<typename F, Iterable I, typename Err = typename decltype(std::declval<F>()( std::declval<std::remove_const_t<typename decltype(std::declval<I>().iter())::IterElem>>()))::Err> |
Result< void, Err > | mtcore::results::foreach (const F &func, const I &iterable) |
| Chains together the execution of an errorable function on a list of arguments If an error is encountered, execution will stop and immediately return No Result value is returned Useful for performing side effects.
|
|
template<typename F, typename... Args, typename Err = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Err> |
Result< void, Err > | mtcore::results::chain (const F &func, const Args &...args) |
| Chains together the execution of an errorable function on a list of arguments If an error is encountered, execution will stop and immediately return No Result value is returned Useful for performing side effects.
|
|
template<typename Success, typename Acc, typename F, typename... Args, typename Err = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Err> |
Result< Success, Err > | mtcore::results::reduce (Success initVal, const Acc &acc, const F &func, const Args &...args) |
| Reduces arguments with errorable function If an error is encountered, execution will stop and immediately return The accumulated Result will be what's returned on success Useful for reduction/mapping.
|
|
template<typename F, typename... Args, typename Out = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Value, typename Err = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Err> |
auto | mtcore::results::map (const F &func, const Args &...args) |
| Maps values with function that may error.
|
|
Results that can hold success (with optional success value) or an error.
template<typename F, typename... Args, typename Err = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Err>
Result< void, Err > mtcore::results::chain |
( |
const F & | func, |
|
|
const Args &... | args ) |
Chains together the execution of an errorable function on a list of arguments If an error is encountered, execution will stop and immediately return No Result value is returned Useful for performing side effects.
- Template Parameters
-
F | Type of function to execute |
Args | Type of variadic arguments |
Err | Type of Result Error |
- Parameters
-
func | Function to execute |
args | Arguments to execute function on |
- Returns
- Result of success or error
Definition at line 539 of file result.hpp.
539 {
540 return impl::Chain<Err, F, Args...>::run(func, args...);
541 }
template<typename F, Iterable I, typename Err = typename decltype(std::declval<F>()( std::declval<std::remove_const_t<typename decltype(std::declval<I>().iter())::IterElem>>()))::Err>
Result< void, Err > mtcore::results::foreach |
( |
const F & | func, |
|
|
const I & | iterable ) |
Chains together the execution of an errorable function on a list of arguments If an error is encountered, execution will stop and immediately return No Result value is returned Useful for performing side effects.
- Template Parameters
-
- Parameters
-
func | Function to execute |
iterable | Iterable to execute function on |
- Returns
- Result of success or error
Definition at line 483 of file result.hpp.
483 {
484 auto iter = iterable.iter();
485 using Elem = std::remove_cv_t<
typename decltype(
iter)::IterElem>;
486 Elem cur;
487 while (
iter.next().move_if_present(cur)) {
488 auto res = func(cur);
489 if (res.is_error()) {
490 return res.error();
491 }
492 }
494 }
template<typename F, typename... Args, typename Out = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Value, typename Err = typename decltype(std::declval<F>()(std::declval<typename impl::FirstVariadic<Args...>::Type>()))::Err>
auto mtcore::results::map |
( |
const F & | func, |
|
|
const Args &... | args ) |
Maps values with function that may error.
Results are put into a tuple If an error is encountered, execution will stop and immediately return
- Template Parameters
-
F | Function to map with |
Args | Arguments to map |
Out | Type of success output |
Err | Type of error in Result |
- Parameters
-
func | Function to use to map objects |
args | Arguments to map |
- Returns
- Tuple of mapped success values on success, or error on failure
Definition at line 585 of file result.hpp.
585 {
586 return impl::Map<Out, Err, F, Args...>::run(func, args...);
587 }