pstore2
Classes | Typedefs | Functions
error_or.hpp File Reference

error_or<T> holds either an instance of T or a std:error. More...

#include <new>
#include <system_error>
#include <tuple>
#include "pstore/adt/utility.hpp"
#include "pstore/support/assert.hpp"
#include "pstore/support/gsl.hpp"
#include "pstore/support/inherit_const.hpp"
Include dependency graph for error_or.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pstore::is_error< Error >
 
class  pstore::error_or< T >
 
struct  pstore::details::applier< N >
 
struct  pstore::details::applier< std::size_t{0}>
 

Typedefs

template<typename... Args>
using pstore::error_or_n = error_or< std::tuple< Args... > >
 

Functions

template<typename T , typename Function >
auto pstore::operator>>= (error_or< T > &&t, Function f) -> decltype((f(t.get())))
 The monadic "bind" operator for error_or<T>. More...
 
template<std::size_t I, class... Types>
std::tuple_element< I, std::tuple< Types... > >::type & pstore::get (error_or_n< Types... > &eon) noexcept
 
template<std::size_t I, class... Types>
std::tuple_element< I, std::tuple< Types... > >::type && pstore::get (error_or_n< Types... > &&eon) noexcept
 
template<std::size_t I, class... Types>
std::tuple_element< I, std::tuple< Types... > >::type const & pstore::get (error_or_n< Types... > const &eon) noexcept
 
template<typename Function , typename Tuple >
auto pstore::details::apply (Function &&f, Tuple &&t) -> decltype(applier< std::tuple_size< typename std::decay< Tuple >::type >::value >::apply(std::forward< Function >(f), std::forward< Tuple >(t)))
 
template<typename Function , typename... Args>
auto pstore::operator>>= (error_or_n< Args... > const &t, Function &&f) -> decltype(details::apply(f, t.get()))
 

Detailed Description

error_or<T> holds either an instance of T or a std:error.

Function Documentation

◆ operator>>=()

template<typename T , typename Function >
auto pstore::operator>>= ( error_or< T > &&  t,
Function  f 
) -> decltype ((f (t.get ())))

The monadic "bind" operator for error_or<T>.

If t has an error then then returns the error where the return type is derived from the return type of f. If t has a value then returns the result of calling f.

Template Parameters
TThe input type wrapped by a error_or<>.
FunctionA callable object whose signature is of the form error_or<U> f(T t).