Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
fishnet::Either< T, E > Class Template Reference

#include <Either.hpp>

Inheritance diagram for fishnet::Either< T, E >:
Collaboration diagram for fishnet::Either< T, E >:

Public Member Functions

template<typename... Args>
 Either (Args &&... args)
 
const T & value_or_throw () const &
 Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.
 
T & value_or_throw () &
 Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.
 
T && value_or_throw () &&
 Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.
 
const T & value_or_throw (const std::string &errorMsg) const &
 Get the value of the Either if it has a value, otherwise throw an exception with the provided message.
 
T & value_or_throw (const std::string &errorMsg) &
 Get the value of the Either if it has a value, otherwise throw an exception with the provided message.
 
T && value_or_throw (const std::string &errorMsg) &&
 Get the value of the Either if it has a value, otherwise throw an exception with the provided message.
 
template<typename F >
requires fishnet::util::UnaryFunction<F,T,Either<typename std::remove_cvref_t<std::invoke_result_t<F,T>>::value_type,E>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >::value_type, E > and_then (F &&f) &
 flatMap the value of the Either if it has a value, otherwise return the error
 
template<typename F >
requires fishnet::util::UnaryFunction<F,T,Either<typename std::remove_cvref_t<std::invoke_result_t<F,T>>::value_type,E>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >::value_type, E > and_then (F &&f) &&
 flatMap the value of the Either if it has a value, otherwise return the error
 
template<typename F >
requires fishnet::util::UnaryFunction<F,T, typename std::remove_cvref_t<std::invoke_result_t<F,T>>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >, E > transform (F &&f) &
 Transform the value of the Either if it has a value, otherwise return the error.
 
template<typename F >
requires fishnet::util::UnaryFunction<F,T, typename std::remove_cvref_t<std::invoke_result_t<F,T>>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >, E > transform (F &&f) &&
 Transform the value of the Either if it has a value, otherwise return the error.
 
template<typename F >
requires std::convertible_to<std::invoke_result_t<F>,Either<T,E>>
Either< T, E > or_else (F &&f) &
 If the Either has a value, return it. Otherwise, call the provided function and return its result.
 
template<typename F >
requires std::convertible_to<std::invoke_result_t<F>,Either<T,E>>
Either< T, E > or_else (F &&f) &&
 If the Either has a value, return it. Otherwise, call the provided function and return its result.
 
void if_value (fishnet::util::Consumer< T > auto const &consumer)
 If the Either has a value, call the provided function with the value. Otherwise, do nothing.
 
void if_value_or_error (fishnet::util::Consumer< T > auto const &consumer, fishnet::util::Consumer< E > auto const &errorConsumer)
 If the Either has a value, call the provided function with the value. Otherwise, call the provided function with the error.
 

Constructor & Destructor Documentation

◆ Either()

template<typename T , typename E >
template<typename... Args>
fishnet::Either< T, E >::Either ( Args &&...  args)
inline

Member Function Documentation

◆ and_then() [1/2]

template<typename T , typename E >
template<typename F >
requires fishnet::util::UnaryFunction<F,T,Either<typename std::remove_cvref_t<std::invoke_result_t<F,T>>::value_type,E>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >::value_type, E > fishnet::Either< T, E >::and_then ( F &&  f) &
inline

flatMap the value of the Either if it has a value, otherwise return the error

Template Parameters
F(T) -> Either<U,E>
Parameters
fflatMap function
Returns
Either<U,E>

◆ and_then() [2/2]

template<typename T , typename E >
template<typename F >
requires fishnet::util::UnaryFunction<F,T,Either<typename std::remove_cvref_t<std::invoke_result_t<F,T>>::value_type,E>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >::value_type, E > fishnet::Either< T, E >::and_then ( F &&  f) &&
inline

flatMap the value of the Either if it has a value, otherwise return the error

Template Parameters
F(T&&) -> Either<U,E>
Parameters
fflatMap function
Returns
Either<U,E>

◆ if_value()

template<typename T , typename E >
void fishnet::Either< T, E >::if_value ( fishnet::util::Consumer< T > auto const &  consumer)
inline

If the Either has a value, call the provided function with the value. Otherwise, do nothing.

Parameters
consumer(T) -> void
Returns
void

◆ if_value_or_error()

template<typename T , typename E >
void fishnet::Either< T, E >::if_value_or_error ( fishnet::util::Consumer< T > auto const &  consumer,
fishnet::util::Consumer< E > auto const &  errorConsumer 
)
inline

If the Either has a value, call the provided function with the value. Otherwise, call the provided function with the error.

Parameters
consumer(T) -> void
errorConsumer(E) -> void
Returns
void

◆ or_else() [1/2]

template<typename T , typename E >
template<typename F >
requires std::convertible_to<std::invoke_result_t<F>,Either<T,E>>
Either< T, E > fishnet::Either< T, E >::or_else ( F &&  f) &
inline

If the Either has a value, return it. Otherwise, call the provided function and return its result.

Template Parameters
F() -> Either<T,E>
Parameters
ffunction to call if the Either is empty
Returns
Either<T,E>

◆ or_else() [2/2]

template<typename T , typename E >
template<typename F >
requires std::convertible_to<std::invoke_result_t<F>,Either<T,E>>
Either< T, E > fishnet::Either< T, E >::or_else ( F &&  f) &&
inline

If the Either has a value, return it. Otherwise, call the provided function and return its result.

Template Parameters
F() -> Either<T,E>
Parameters
ffunction to call if the Either is empty
Returns
Either<T,E> &&

◆ transform() [1/2]

template<typename T , typename E >
template<typename F >
requires fishnet::util::UnaryFunction<F,T, typename std::remove_cvref_t<std::invoke_result_t<F,T>>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >, E > fishnet::Either< T, E >::transform ( F &&  f) &
inline

Transform the value of the Either if it has a value, otherwise return the error.

Template Parameters
F(T) -> U
Parameters
fmap function
Returns
Either<U,E>

◆ transform() [2/2]

template<typename T , typename E >
template<typename F >
requires fishnet::util::UnaryFunction<F,T, typename std::remove_cvref_t<std::invoke_result_t<F,T>>>
Either< typename std::remove_cvref_t< std::invoke_result_t< F, T > >, E > fishnet::Either< T, E >::transform ( F &&  f) &&
inline

Transform the value of the Either if it has a value, otherwise return the error.

Template Parameters
F(T&&) -> U
Parameters
fmap function
Returns
Either<U,E>

◆ value_or_throw() [1/6]

template<typename T , typename E >
T & fishnet::Either< T, E >::value_or_throw ( ) &
inline

Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.

Returns
T& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

◆ value_or_throw() [2/6]

template<typename T , typename E >
T && fishnet::Either< T, E >::value_or_throw ( ) &&
inline

Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.

Returns
T&& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

◆ value_or_throw() [3/6]

template<typename T , typename E >
const T & fishnet::Either< T, E >::value_or_throw ( ) const &
inline

Get the value of the Either if it has a value, otherwise throw an exception using the error value if applicable, or a default message.

Returns
const T& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

◆ value_or_throw() [4/6]

template<typename T , typename E >
T & fishnet::Either< T, E >::value_or_throw ( const std::string &  errorMsg) &
inline

Get the value of the Either if it has a value, otherwise throw an exception with the provided message.

Parameters
errorMsgThe message to include in the exception if the Either is empty.
Returns
T& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

◆ value_or_throw() [5/6]

template<typename T , typename E >
T && fishnet::Either< T, E >::value_or_throw ( const std::string &  errorMsg) &&
inline

Get the value of the Either if it has a value, otherwise throw an exception with the provided message.

Parameters
errorMsgThe message to include in the exception if the Either is empty.
Returns
T&& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

◆ value_or_throw() [6/6]

template<typename T , typename E >
const T & fishnet::Either< T, E >::value_or_throw ( const std::string &  errorMsg) const &
inline

Get the value of the Either if it has a value, otherwise throw an exception with the provided message.

Parameters
errorMsgThe message to include in the exception if the Either is empty.
Returns
const T& the value of the Either.
Exceptions
std::runtime_errorif the Either is empty.

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