Result
result.hpp File Reference

This header contains the 'result' monadic type for indicating possible error conditions. More...

#include <cstddef>
#include <type_traits>
#include <new>
#include <memory>
#include <functional>
#include <utility>
#include <initializer_list>
#include <string>
#include <stdexcept>
+ Include dependency graph for result.hpp:

Go to the source code of this file.

Classes

struct  cpp::bitwizeshift::in_place_t
 A structure for representing in-place construction. More...
 
struct  cpp::bitwizeshift::in_place_error_t
 A structure for representing in-place construction of an error type. More...
 
class  cpp::bitwizeshift::failure< E >
 A semantic type used for distinguishing failure values in an API that returns result types. More...
 
class  cpp::bitwizeshift::result< T, E >
 The class template result manages result results from APIs, while encoding possible failure conditions. More...
 
class  cpp::bitwizeshift::bad_result_access< E >
 An exception thrown when result::value is accessed without a contained value. More...
 
struct  cpp::bitwizeshift::is_failure< T >
 
struct  cpp::bitwizeshift::is_failure< failure< E > >
 
struct  cpp::bitwizeshift::is_result< T >
 
struct  cpp::bitwizeshift::is_result< result< T, E > >
 
class  cpp::bitwizeshift::bad_result_access< E >
 An exception thrown when result::value is accessed without a contained value. More...
 
class  cpp::bitwizeshift::failure< E >
 A semantic type used for distinguishing failure values in an API that returns result types. More...
 
class  cpp::bitwizeshift::result< T, E >
 The class template result manages result results from APIs, while encoding possible failure conditions. More...
 
class  cpp::bitwizeshift::result< void, E >
 Partial specialization of result<void, E> More...
 
struct  std::hash<::RESULT_NS_IMPL::result< T, E > >
 
struct  std::hash<::RESULT_NS_IMPL::result< void, E > >
 

Macros

#define RESULT_CPP14_CONSTEXPR
 
#define RESULT_CPP17_INLINE
 
#define RESULT_INLINE_VISIBILITY
 
#define RESULT_WARN_UNUSED
 
#define RESULT_NODISCARD
 
#define RESULT_NAMESPACE_INTERNAL   cpp
 
#define RESULT_NS_IMPL   RESULT_NAMESPACE_INTERNAL::bitwizeshift
 

Typedefs

template<typename Fn , typename... Args>
using cpp::bitwizeshift::detail::invoke_result_t = typename invoke_result< Fn, Args... >::type
 
template<typename T >
using cpp::bitwizeshift::detail::wrapped_result_type = typename std::conditional< std::is_lvalue_reference< T >::value, std::reference_wrapper< typename std::remove_reference< T >::type >, typename std::remove_const< T >::type >::type
 
template<typename E , typename E2 >
using cpp::bitwizeshift::detail::failure_is_value_convertible = std::integral_constant< bool,(std::is_constructible< E, E2 && >::value &&!std::is_same< typename std::decay< E2 >::type, in_place_t >::value &&!is_failure< typename std::decay< E2 >::type >::value &&!is_result< typename std::decay< E2 >::type >::value)>
 
template<typename E , typename E2 >
using cpp::bitwizeshift::detail::failure_is_explicit_value_convertible = std::integral_constant< bool,(failure_is_value_convertible< E, E2 >::value &&!std::is_convertible< E2, E >::value)>
 
template<typename E , typename E2 >
using cpp::bitwizeshift::detail::failure_is_implicit_value_convertible = std::integral_constant< bool,(failure_is_value_convertible< E, E2 >::value &&std::is_convertible< E2, E >::value)>
 
template<typename E , typename E2 >
using cpp::bitwizeshift::detail::failure_is_value_assignable = std::integral_constant< bool,(!is_result< typename std::decay< E2 >::type >::value &&!is_failure< typename std::decay< E2 >::type >::value &&std::is_assignable< wrapped_result_type< E > &, E2 >::value)>
 
template<bool Condition, typename Base >
using cpp::bitwizeshift::detail::conditionally_nest_type = typename std::conditional< Condition, typename Base::base_type, Base >::type
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_trivial_copy_ctor_base = conditionally_nest_type< std::is_trivially_copy_constructible< T >::value &&std::is_trivially_copy_constructible< E >::value, result_trivial_copy_ctor_base_impl< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_trivial_move_ctor_base = conditionally_nest_type< std::is_trivially_move_constructible< T >::value &&std::is_trivially_move_constructible< E >::value, result_trivial_move_ctor_base_impl< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_trivial_copy_assign_base = conditionally_nest_type< std::is_trivially_copy_constructible< T >::value &&std::is_trivially_copy_constructible< E >::value &&std::is_trivially_copy_assignable< T >::value &&std::is_trivially_copy_assignable< E >::value &&std::is_trivially_destructible< T >::value &&std::is_trivially_destructible< E >::value, result_trivial_copy_assign_base_impl< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_trivial_move_assign_base = conditionally_nest_type< std::is_trivially_move_constructible< T >::value &&std::is_trivially_move_constructible< E >::value &&std::is_trivially_move_assignable< T >::value &&std::is_trivially_move_assignable< E >::value &&std::is_trivially_destructible< T >::value &&std::is_trivially_destructible< E >::value, result_trivial_move_assign_base_impl< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_copy_ctor_base = conditionally_nest_type< std::is_copy_constructible< T >::value &&std::is_copy_constructible< E >::value, disable_copy_ctor< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_move_ctor_base = conditionally_nest_type< std::is_move_constructible< T >::value &&std::is_move_constructible< E >::value, disable_move_ctor< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_copy_assign_base = conditionally_nest_type< std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_constructible< E >::value &&std::is_copy_assignable< wrapped_result_type< T > >::value &&std::is_copy_assignable< E >::value, disable_move_assignment< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_move_assign_base = conditionally_nest_type< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_constructible< E >::value &&std::is_move_assignable< wrapped_result_type< T > >::value &&std::is_move_assignable< E >::value, disable_copy_assignment< T, E > >
 
template<typename T , typename E >
using cpp::bitwizeshift::detail::result_storage = result_move_assign_base< T, E >
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_convertible = std::integral_constant< bool,(std::is_constructible< T1, result< T2, E2 > & >::value||std::is_constructible< T1, const result< T2, E2 > & >::value||std::is_constructible< T1, result< T2, E2 > && >::value||std::is_constructible< T1, const result< T2, E2 > && >::value||std::is_constructible< E1, result< T2, E2 > & >::value||std::is_constructible< E1, const result< T2, E2 > & >::value||std::is_constructible< E1, result< T2, E2 > && >::value||std::is_constructible< E1, const result< T2, E2 > && >::value||std::is_convertible< result< T2, E2 > &, T1 >::value||std::is_convertible< const result< T2, E2 > &, T1 >::value||std::is_convertible< result< T2, E2 > &&, T1 >::value||std::is_convertible< const result< T2, E2 > &&, T1 >::value||std::is_convertible< result< T2, E2 > &, E1 >::value||std::is_convertible< const result< T2, E2 > &, E1 >::value||std::is_convertible< result< T2, E2 > &&, E1 >::value||std::is_convertible< const result< T2, E2 > &&, E1 >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_copy_convertible = std::integral_constant< bool,(!result_is_convertible< T1, E1, T2, E2 >::value &&std::is_constructible< T1, const T2 & >::value &&std::is_constructible< E1, const E2 & >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_implicit_copy_convertible = std::integral_constant< bool,(result_is_copy_convertible< T1, E1, T2, E2 >::value &&std::is_convertible< const T2 &, T1 >::value &&std::is_convertible< const E2 &, E1 >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_explicit_copy_convertible = std::integral_constant< bool,(result_is_copy_convertible< T1, E1, T2, E2 >::value &&(!std::is_convertible< const T2 &, T1 >::value||!std::is_convertible< const E2 &, E1 >::value))>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_move_convertible = std::integral_constant< bool,(!result_is_convertible< T1, E1, T2, E2 >::value &&std::is_constructible< T1, T2 && >::value &&std::is_constructible< E1, E2 && >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_implicit_move_convertible = std::integral_constant< bool,(result_is_move_convertible< T1, E1, T2, E2 >::value &&std::is_convertible< T2 &&, T1 >::value &&std::is_convertible< E2 &&, E1 >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_explicit_move_convertible = std::integral_constant< bool,(result_is_move_convertible< T1, E1, T2, E2 >::value &&(!std::is_convertible< T2 &&, T1 >::value||!std::is_convertible< E2 &&, E1 >::value))>
 
template<typename T , typename U >
using cpp::bitwizeshift::detail::result_is_value_convertible = std::integral_constant< bool,(std::is_constructible< T, U && >::value &&!std::is_same< typename std::decay< U >::type, in_place_t >::value &&!std::is_same< typename std::decay< U >::type, in_place_error_t >::value &&!is_result< typename std::decay< U >::type >::value)>
 
template<typename T , typename U >
using cpp::bitwizeshift::detail::result_is_explicit_value_convertible = std::integral_constant< bool,(result_is_value_convertible< T, U >::value &&!std::is_convertible< U &&, T >::value)>
 
template<typename T , typename U >
using cpp::bitwizeshift::detail::result_is_implicit_value_convertible = std::integral_constant< bool,(result_is_value_convertible< T, U >::value &&std::is_convertible< U &&, T >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_convert_assignable = std::integral_constant< bool,(result_is_convertible< T1, E1, T2, E2 >::value &&std::is_assignable< T1 &, result< T2, E2 > & >::value &&std::is_assignable< T1 &, const result< T2, E2 > & >::value &&std::is_assignable< T1 &, result< T2, E2 > && >::value &&std::is_assignable< T1 &, const result< T2, E2 > && >::value &&std::is_assignable< E1 &, result< T2, E2 > & >::value &&std::is_assignable< E1 &, const result< T2, E2 > & >::value &&std::is_assignable< E1 &, result< T2, E2 > && >::value &&std::is_assignable< E1 &, const result< T2, E2 > && >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_copy_convert_assignable = std::integral_constant< bool,(!result_is_convert_assignable< T1, E1, T2, E2 >::value &&std::is_nothrow_constructible< T1, const T2 & >::value &&std::is_assignable< wrapped_result_type< T1 > &, const T2 & >::value &&std::is_nothrow_constructible< E1, const E2 & >::value &&std::is_assignable< E1 &, const E2 & >::value)>
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
using cpp::bitwizeshift::detail::result_is_move_convert_assignable = std::integral_constant< bool,(!result_is_convert_assignable< T1, E1, T2, E2 >::value &&std::is_nothrow_constructible< T1, T2 && >::value &&std::is_assignable< T1 &, T2 && >::value &&std::is_nothrow_constructible< E1, E2 && >::value &&std::is_assignable< E1 &, E2 && >::value)>
 
template<typename T , typename U >
using cpp::bitwizeshift::detail::result_is_value_assignable = std::integral_constant< bool,(!is_result< typename std::decay< U >::type >::value &&!is_failure< typename std::decay< U >::type >::value &&std::is_nothrow_constructible< T, U >::value &&std::is_assignable< wrapped_result_type< T > &, U >::value &&(!std::is_same< typename std::decay< U >::type, typename std::decay< T >::type >::value||!std::is_scalar< T >::value))>
 
template<typename E , typename E2 >
using cpp::bitwizeshift::detail::result_is_failure_assignable = std::integral_constant< bool,(std::is_nothrow_constructible< E, E2 >::value &&std::is_assignable< E &, E2 >::value)>
 

Functions

template<typename T >
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::forward (typename std::remove_reference< T >::type &t) noexcept -> T &&
 
template<typename T >
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::forward (typename std::remove_reference< T >::type &&t) noexcept -> T &&
 
template<typename Base , typename T , typename Derived , typename... Args, typename = typename std::enable_if< std::is_function<T>::value && std::is_base_of<Base, typename std::decay<Derived>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmf, Derived &&ref, Args &&... args) noexcept(noexcept((::RESULT_NS_IMPL::detail::forward< Derived >(ref).*pmf)(::RESULT_NS_IMPL::detail::forward< Args >(args)...))) -> decltype((::RESULT_NS_IMPL::detail::forward< Derived >(ref).*pmf)(::RESULT_NS_IMPL::detail::forward< Args >(args)...))
 
template<typename Base , typename T , typename RefWrap , typename... Args, typename = typename std::enable_if< std::is_function<T>::value && is_reference_wrapper<typename std::decay<RefWrap>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmf, RefWrap &&ref, Args &&... args) noexcept(noexcept((ref.get().*pmf)(std::forward< Args >(args)...))) -> decltype((ref.get().*pmf)(RESULT_NS_IMPL::detail::forward< Args >(args)...))
 
template<typename Base , typename T , typename Pointer , typename... Args, typename = typename std::enable_if< std::is_function<T>::value && !is_reference_wrapper<typename std::decay<Pointer>::type>::value && !std::is_base_of<Base, typename std::decay<Pointer>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmf, Pointer &&ptr, Args &&... args) noexcept(noexcept(((*std::forward< Pointer >(ptr)).*pmf)(std::forward< Args >(args)...))) -> decltype(((*RESULT_NS_IMPL::detail::forward< Pointer >(ptr)).*pmf)(RESULT_NS_IMPL::detail::forward< Args >(args)...))
 
template<typename Base , typename T , typename Derived , typename = typename std::enable_if< !std::is_function<T>::value && std::is_base_of<Base, typename std::decay<Derived>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmd, Derived &&ref) noexcept(noexcept(std::forward< Derived >(ref).*pmd)) -> decltype(RESULT_NS_IMPL::detail::forward< Derived >(ref).*pmd)
 
template<typename Base , typename T , typename RefWrap , typename = typename std::enable_if< !std::is_function<T>::value && is_reference_wrapper<typename std::decay<RefWrap>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmd, RefWrap &&ref) noexcept(noexcept(ref.get().*pmd)) -> decltype(ref.get().*pmd)
 
template<typename Base , typename T , typename Pointer , typename = typename std::enable_if< !std::is_function<T>::value && !is_reference_wrapper<typename std::decay<Pointer>::type>::value && !std::is_base_of<Base, typename std::decay<Pointer>::type>::value >::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (T Base::*pmd, Pointer &&ptr) noexcept(noexcept((*std::forward< Pointer >(ptr)).*pmd)) -> decltype((*RESULT_NS_IMPL::detail::forward< Pointer >(ptr)).*pmd)
 
template<typename F , typename... Args, typename = typename std::enable_if<!std::is_member_pointer<typename std::decay<F>::type>::value>::type>
RESULT_INLINE_VISIBILITY constexpr auto cpp::bitwizeshift::detail::invoke (F &&f, Args &&... args) noexcept(noexcept(std::forward< F >(f)(std::forward< Args >(args)...))) -> decltype(RESULT_NS_IMPL::detail::forward< F >(f)(RESULT_NS_IMPL::detail::forward< Args >(args)...))
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator== (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator!= (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator< (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator> (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator<= (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator>= (const failure< E1 > &lhs, const failure< E2 > &rhs) noexcept -> bool
 
template<typename E >
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail (E &&e) noexcept(std::is_nothrow_constructible< typename std::decay< E >::type, E >::value) -> failure< typename std::decay< E >::type >
 Deduces and constructs a failure type from e. More...
 
template<typename E >
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail (std::reference_wrapper< E > e) noexcept -> failure< E &>
 Deduces a failure reference from a reverence_wrapper. More...
 
template<typename E , typename... Args, typename = typename std::enable_if<std::is_constructible<E,Args...>::value>::type>
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail (Args &&...args) noexcept(std::is_nothrow_constructible< E, Args... >::value) -> failure< E >
 Constructs a failure type from a series of arguments. More...
 
template<typename E , typename U , typename... Args, typename = typename std::enable_if<std::is_constructible<E,std::initializer_list<U>,Args...>::value>::type>
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail (std::initializer_list< U > ilist, Args &&...args) noexcept(std::is_nothrow_constructible< E, std::initializer_list< U >, Args... >::value) -> failure< E >
 Constructs a failure type from an initializer list and series of arguments. More...
 
template<typename E >
auto cpp::bitwizeshift::swap (failure< E > &lhs, failure< E > &rhs) noexcept(std::is_nothrow_move_constructible< E >::value) -> void
 Swaps the contents of two failure values. More...
 
constexpr auto cpp::bitwizeshift::detail::operator== (unit, unit) noexcept -> bool
 
constexpr auto cpp::bitwizeshift::detail::operator!= (unit, unit) noexcept -> bool
 
constexpr auto cpp::bitwizeshift::detail::operator< (unit, unit) noexcept -> bool
 
constexpr auto cpp::bitwizeshift::detail::operator> (unit, unit) noexcept -> bool
 
constexpr auto cpp::bitwizeshift::detail::operator<= (unit, unit) noexcept -> bool
 
constexpr auto cpp::bitwizeshift::detail::operator>= (unit, unit) noexcept -> bool
 
template<typename T , typename E >
constexpr auto cpp::bitwizeshift::detail::extract_error (const result< T, E > &exp) noexcept -> const E &
 
template<typename E >
auto cpp::bitwizeshift::detail::throw_bad_result_access (E &&error) -> void
 
template<typename String , typename E >
auto cpp::bitwizeshift::detail::throw_bad_result_access_message (String &&message, E &&error) -> void
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator== (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator!= (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator>= (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator<= (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator> (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename T1 , typename E1 , typename T2 , typename E2 >
constexpr auto cpp::bitwizeshift::operator< (const result< T1, E1 > &lhs, const result< T2, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator== (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator!= (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator>= (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator<= (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator> (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename E1 , typename E2 >
constexpr auto cpp::bitwizeshift::operator< (const result< void, E1 > &lhs, const result< void, E2 > &rhs) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator== (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator== (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator!= (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator!= (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator<= (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator<= (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator>= (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator>= (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator< (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator< (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U , typename = typename std::enable_if<!std::is_same<T,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator> (const result< T, E > &exp, const U &value) noexcept -> bool
 
template<typename T , typename U , typename E , typename = typename std::enable_if<!std::is_same<U,void>::value>::type>
constexpr auto cpp::bitwizeshift::operator> (const T &value, const result< U, E > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator== (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator== (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator!= (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator!= (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator<= (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator<= (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator>= (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator>= (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator< (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator< (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E , typename U >
constexpr auto cpp::bitwizeshift::operator> (const result< T, E > &exp, const failure< U > &value) noexcept -> bool
 
template<typename T , typename U , typename E >
constexpr auto cpp::bitwizeshift::operator> (const failure< T > &value, const result< E, U > &exp) noexcept -> bool
 
template<typename T , typename E >
auto cpp::bitwizeshift::swap (result< T, E > &lhs, result< T, E > &rhs) noexcept(std::is_nothrow_move_constructible< result< T, E >>::value &&std::is_nothrow_move_assignable< result< T, E >>::value) -> void
 Swaps the contents of lhs with rhs. More...
 
template<typename E >
auto cpp::bitwizeshift::swap (result< void, E > &lhs, result< void, E > &rhs) noexcept(std::is_nothrow_move_constructible< result< void, E >>::value &&std::is_nothrow_move_assignable< result< void, E >>::value) -> void
 Swaps the contents of lhs with rhs. More...
 

Variables

RESULT_CPP17_INLINE constexpr auto cpp::bitwizeshift::in_place = in_place_t{}
 
RESULT_CPP17_INLINE constexpr auto cpp::bitwizeshift::in_place_error = in_place_error_t{}
 

Detailed Description

This header contains the 'result' monadic type for indicating possible error conditions.

Definition in file result.hpp.

Function Documentation

◆ fail() [1/4]

template<typename E >
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail ( E &&  e) const -> failure< typename std::decay< E >::type >
noexcept

Deduces and constructs a failure type from e.

Parameters
ethe failure value
Returns
a constructed failure value

◆ fail() [2/4]

template<typename E >
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail ( std::reference_wrapper< E >  e) -> failure< E &>
noexcept

Deduces a failure reference from a reverence_wrapper.

Parameters
ethe failure value
Returns
a constructed failure reference

◆ fail() [3/4]

template<typename E , typename... Args, typename = typename std::enable_if<std::is_constructible<E,Args...>::value>::type>
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail ( Args &&...  args) const -> failure< E >
noexcept

Constructs a failure type from a series of arguments.

Template Parameters
Ethe failure type
Parameters
argsthe arguments to forward to E's constructor
Returns
a constructed failure type

◆ fail() [4/4]

template<typename E , typename U , typename... Args, typename = typename std::enable_if<std::is_constructible<E,std::initializer_list<U>,Args...>::value>::type>
RESULT_WARN_UNUSED constexpr auto cpp::bitwizeshift::fail ( std::initializer_list< U >  ilist,
Args &&...  args 
) const -> failure< E >
noexcept

Constructs a failure type from an initializer list and series of arguments.

Template Parameters
Ethe failure type
Parameters
argsthe arguments to forward to E's constructor
Returns
a constructed failure type

◆ swap() [1/3]

template<typename E >
auto cpp::bitwizeshift::swap ( failure< E > &  lhs,
failure< E > &  rhs 
) const -> void
noexcept

Swaps the contents of two failure values.

Parameters
lhsthe left failure
rhsthe right failure

◆ swap() [2/3]

template<typename T , typename E >
auto cpp::bitwizeshift::swap ( result< T, E > &  lhs,
result< T, E > &  rhs 
) const && -> void
noexcept

Swaps the contents of lhs with rhs.

Parameters
lhsthe left result
rhsthe right result

◆ swap() [3/3]

template<typename E >
auto cpp::bitwizeshift::swap ( result< void, E > &  lhs,
result< void, E > &  rhs 
) const && -> void
noexcept

Swaps the contents of lhs with rhs.

Parameters
lhsthe left result
rhsthe right result