rsl 1.1.0
ROS Support Library
|
#include <tl_expected/expected.hpp>
#include <optional>
Go to the source code of this file.
Functions | |
template<typename T , typename Fn > | |
constexpr auto | rsl::mbind (std::optional< T > const &opt, Fn fn) -> std::invoke_result_t< Fn, T > |
Monad optional bind. | |
template<typename T , typename E , typename Fn > | |
constexpr auto | rsl::mbind (tl::expected< T, E > const &exp, Fn fn) -> std::invoke_result_t< Fn, T > |
Monad tl::expected<T,E> | |
template<typename Fn > | |
auto | rsl::mtry (Fn fn) -> tl::expected< std::invoke_result_t< Fn >, std::exception_ptr > try |
Monadic try, used to lift a function that throws an exception into one that returns an tl::expected<T, std::exception_ptr> | |
rsl::catch (...) | |
template<typename Fn , typename G > | |
constexpr auto | rsl::mcompose (Fn fn, G g) |
Monadic compose two monad functions. | |
template<typename T , typename G , typename... Ts> | |
constexpr auto | rsl::mcompose (T t, G g, Ts... vars) |
Variadic mcompose. | |
template<typename T , typename E > | |
constexpr auto | rsl::has_error (tl::expected< T, E > const &exp) |
Test if expected type is Error. | |
template<typename T , typename E > | |
constexpr auto | rsl::has_value (tl::expected< T, E > const &exp) |
Test if expected type is Value. | |
template<typename E , typename... Args> | |
constexpr auto | rsl::maybe_error (tl::expected< Args, E >... args) |
Tests if any of the expected args passed in has an error. | |
template<typename T , typename Fn , typename = std::enable_if_t<rsl::is_optional<T>>, typename = std::enable_if_t<std::is_invocable_v< Fn, typename std::remove_cv_t<std::remove_reference_t<T>>::value_type>>> | |
constexpr auto | operator| (T &&opt, Fn &&fn) |
Overload of the | operator as bind. | |
template<typename T , typename E , typename Fn > | |
constexpr auto | operator| (tl::expected< T, E > const &exp, Fn fn) |
Overload of the | operator as bind. | |
template<typename T , typename Fn , typename = std::enable_if_t<!rsl::is_optional<T>>> | |
constexpr auto | operator| (T &&val, Fn &&fn) -> typename std::enable_if_t< std::is_invocable_v< Fn, T >, std::invoke_result_t< Fn, T > > |
Overload of the | operator for unary functions. | |
Variables | |
template<typename > | |
constexpr bool | rsl::is_optional_impl = false |
template<typename T > | |
constexpr bool | rsl::is_optional = is_optional_impl<std::remove_cv_t<std::remove_reference_t<T>>> |
|
constexpr |
Test if expected type is Error.
exp | Input tl::expected<T,E> value |
|
constexpr |
Test if expected type is Value.
exp | Input tl::expected<T,E> value |
|
constexpr |
Tests if any of the expected args passed in has an error.
args | tl::expected<T, E> parameter pack |
E | The error type |
Args | The value types for the tl::expected<T, E> args |
|
constexpr |
Monad optional bind.
opt | Input optional |
fn | Function, must return a optional |
T | Input type |
Fn | Function |
|
constexpr |
Monad tl::expected<T,E>
exp | tl::expected<T,E> input |
fn | Function to apply |
T | Type for the input expected |
E | Error type |
Fn | Function |
|
constexpr |
Monadic compose two monad functions.
fn | First function |
g | Second function |
Fn | Type of the first function |
G | Type of the second function |
|
constexpr |
Variadic mcompose.
t | First function |
g | Second function |
vars | Rest of the functions |
T | Type of the first function |
G | Type of the second function |
Ts | Types of the rest of the functions |
auto rsl::mtry | ( | Fn | fn | ) | -> tl::expected<std::invoke_result_t<Fn>, std::exception_ptr> try |
Monadic try, used to lift a function that throws an exception into one that returns an tl::expected<T, std::exception_ptr>
fn | Function to call |
Fn | Function type |
|
constexpr |
Overload of the | operator as bind.
opt | Input optional |
fn | Function |
T | Input type |
Fn | Function |
|
constexpr |
Overload of the | operator for unary functions.
val | Input value |
fn | Function to apply on val |
T | Type for the input |
Fn | Function |
|
constexpr |
Overload of the | operator as bind.
exp | Input tl::expected<T,E> value |
fn | Function to apply |
T | Type for the input expected |
E | Error type |
Fn | Function |