iceberg-cpp
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
iceberg::expected< T, E > Class Template Reference

#include <expected.h>

Inheritance diagram for iceberg::expected< T, E >:
iceberg::expected_detail::move_assign_base< T, E, Enabled, Trivially > iceberg::expected_detail::default_ctor_base< T, E, Enable >

Public Types

typedef T value_type
 
typedef E error_type
 
typedef unexpected< E > unexpected_type
 
template<class U >
using rebind = expected< U, error_type >
 

Public Member Functions

constexpr expected (const expected &rhs)=default
 
constexpr expected (expected &&rhs)=default
 
template<class U , class G , std::enable_if_t<!std::is_same_v< expected< U, G >, expected > > * = nullptr, std::enable_if_t< std::is_convertible_v< const U &, T > &&std::is_convertible_v< const G &, E > > * = nullptr, expected_detail::enable_from_other_expected_t< T, E, U, G, const U &, const G & > * = nullptr>
constexpr expected (const expected< U, G > &rhs) noexcept(std::is_nothrow_constructible_v< T, const U & > &&std::is_nothrow_constructible_v< E, const G & >)
 
template<class U , class G , std::enable_if_t<!std::is_same_v< expected< U, G >, expected > > * = nullptr, std::enable_if_t<!(std::is_convertible_v< const U &, T > &&std::is_convertible_v< const G &, E >)> * = nullptr, expected_detail::enable_from_other_expected_t< T, E, U, G, const U &, const G & > * = nullptr>
constexpr expected (const expected< U, G > &rhs) noexcept(std::is_nothrow_constructible_v< T, const U & > &&std::is_nothrow_constructible_v< E, const G & >)
 
template<class U , class G , std::enable_if_t<!std::is_same_v< expected< U, G >, expected > > * = nullptr, std::enable_if_t< std::is_convertible_v< U, T > &&std::is_convertible_v< G, E > > * = nullptr, expected_detail::enable_from_other_expected_t< T, E, U, G, U, G > * = nullptr>
constexpr expected (expected< U, G > &&rhs) noexcept(std::is_nothrow_constructible_v< T, U > &&std::is_nothrow_constructible_v< E, G >)
 
template<class U , class G , std::enable_if_t<!std::is_same_v< expected< U, G >, expected > > * = nullptr, std::enable_if_t<!(std::is_convertible_v< U, T > &&std::is_convertible_v< G, E >)> * = nullptr, expected_detail::enable_from_other_expected_t< T, E, U, G, U, G > * = nullptr>
constexpr expected (expected< U, G > &&rhs) noexcept(std::is_nothrow_constructible_v< T, U > &&std::is_nothrow_constructible_v< E, G >)
 
template<class U = std::remove_cv_t<T>, std::enable_if_t< std::is_convertible_v< U, T > > * = nullptr, expected_detail::enable_forward_t< T, E, U > * = nullptr>
constexpr expected (U &&v) noexcept(std::is_nothrow_constructible_v< T, U >)
 
template<class U = std::remove_cv_t<T>, std::enable_if_t<!std::is_convertible_v< U, T > > * = nullptr, expected_detail::enable_forward_t< T, E, U > * = nullptr>
constexpr expected (U &&v) noexcept(std::is_nothrow_constructible_v< T, U >)
 
template<class G , std::enable_if_t<!std::is_convertible_v< const G &, E > > * = nullptr, std::enable_if_t< std::is_constructible_v< E, const G & > > * = nullptr>
constexpr expected (const unexpected< G > &e) noexcept(std::is_nothrow_constructible_v< E, const G & >)
 
template<class G , std::enable_if_t< std::is_convertible_v< const G &, E > > * = nullptr, std::enable_if_t< std::is_constructible_v< E, const G & > > * = nullptr>
constexpr expected (unexpected< G > const &e) noexcept(std::is_nothrow_constructible_v< E, const G & >)
 
template<class G , std::enable_if_t<!std::is_convertible_v< G, E > > * = nullptr, std::enable_if_t< std::is_constructible_v< E, G > > * = nullptr>
constexpr expected (unexpected< G > &&e) noexcept(std::is_nothrow_constructible_v< E, G >)
 
template<class G , std::enable_if_t< std::is_convertible_v< G, E > > * = nullptr, std::enable_if_t< std::is_constructible_v< E, G > > * = nullptr>
constexpr expected (unexpected< G > &&e) noexcept(std::is_nothrow_constructible_v< E, G >)
 
template<class... Args, std::enable_if_t< std::is_constructible_v< T, Args... > > * = nullptr>
constexpr expected (std::in_place_t, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args... >)
 
template<class U , class... Args, std::enable_if_t< std::is_constructible_v< T, std::initializer_list< U > &, Args... > > * = nullptr>
constexpr expected (std::in_place_t, std::initializer_list< U > il, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, std::initializer_list< U > &, Args... >)
 
template<class Fn , class... Args>
constexpr expected (expected_detail::construct_with_invoke_result_t tag, Fn &&func, Args &&... args) noexcept(noexcept(static_cast< T >(std::invoke(std::forward< Fn >(func), std::forward< Args >(args)...))))
 
template<class... Args, std::enable_if_t< std::is_constructible_v< E, Args... > > * = nullptr>
constexpr expected (unexpect_t, Args &&... args) noexcept(std::is_nothrow_constructible_v< E, Args... >)
 
template<class U , class... Args, std::enable_if_t< std::is_constructible_v< E, std::initializer_list< U > &, Args... > > * = nullptr>
constexpr expected (unexpect_t, std::initializer_list< U > il, Args &&... args) noexcept(std::is_nothrow_constructible_v< E, std::initializer_list< U > &, Args... >)
 
template<class Fn , class... Args>
constexpr expected (expected_detail::construct_with_invoke_result_t tag1, unexpect_t tag2, Fn &&func, Args &&... args) noexcept(noexcept(static_cast< E >(std::invoke(std::forward< Fn >(func), std::forward< Args >(args)...))))
 
constexpr expected & operator= (const expected &rhs)=default
 
constexpr expected & operator= (expected &&rhs)=default
 
template<class U = std::remove_cv_t<T>, std::enable_if_t<!std::is_same_v< expected, expected_detail::remove_cvref_t< U > > &&!expected_detail::is_specialization_v< expected_detail::remove_cvref_t< U >, unexpected > &&std::is_constructible_v< T, U > &&std::is_assignable_v< T &, U > &&(std::is_nothrow_constructible_v< T, U >||std::is_nothrow_move_constructible_v< T >||std::is_nothrow_move_constructible_v< E >)> * = nullptr>
constexpr expected & operator= (U &&v) noexcept(std::is_nothrow_constructible_v< T, U > &&std::is_nothrow_assignable_v< T &, U >)
 
template<class G , class GF = const G&, std::enable_if_t< std::is_constructible_v< E, GF > &&std::is_assignable_v< E &, GF > &&(std::is_nothrow_constructible_v< E, GF >||std::is_nothrow_move_constructible_v< T >||std::is_nothrow_move_constructible_v< E >)> * = nullptr>
constexpr expected & operator= (const unexpected< G > &rhs) noexcept(std::is_nothrow_constructible_v< E, GF > &&std::is_nothrow_assignable_v< E &, GF >)
 
template<class G , class GF = G, std::enable_if_t< std::is_constructible_v< E, GF > &&std::is_assignable_v< E &, GF > &&(std::is_nothrow_constructible_v< E, GF >||std::is_nothrow_move_constructible_v< T >||std::is_nothrow_move_constructible_v< E >)> * = nullptr>
constexpr expected & operator= (unexpected< G > &&rhs) noexcept(std::is_nothrow_constructible_v< E, GF > &&std::is_nothrow_assignable_v< E &, GF >)
 
template<class... Args, typename std::enable_if_t< std::is_nothrow_constructible_v< T, Args &&... >, bool > = false>
constexpr T & emplace (Args &&... args)
 
template<class U , class... Args, std::enable_if_t< std::is_nothrow_constructible_v< T, std::initializer_list< U > &, Args &&... > > * = nullptr>
constexpr T & emplace (std::initializer_list< U > il, Args &&... args)
 
template<class OT = T, class OE = E>
constexpr std::enable_if_t< std::is_swappable_v< OT > &&std::is_swappable_v< OE > &&std::is_move_constructible_v< OT > &&std::is_move_constructible_v< OE > &&(std::is_nothrow_move_constructible_v< OT >||std::is_nothrow_move_constructible_v< OE >)> swap (expected &rhs) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_swappable_v< T > &&std::is_nothrow_move_constructible_v< E > &&std::is_nothrow_swappable_v< E >)
 
constexpr const T * operator-> () const noexcept
 
constexpr T * operator-> () noexcept
 
constexpr const T & operator* () const &noexcept
 
constexpr T & operator* () &noexcept
 
constexpr const T && operator* () const &&noexcept
 
constexpr T && operator* () &&noexcept
 
constexpr bool has_value () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr const T & value () const &
 
constexpr T & value () &
 
constexpr const T && value () const &&
 
constexpr T && value () &&
 
constexpr const E & error () const &noexcept
 
constexpr E & error () &noexcept
 
constexpr const E && error () const &&noexcept
 
constexpr E && error () &&noexcept
 
template<class U = std::remove_cv_t<T>>
constexpr T value_or (U &&v) const &noexcept(std::is_nothrow_copy_constructible_v< T > &&expected_detail::is_nothrow_convertible_v< U, T >)
 
template<class U = std::remove_cv_t<T>>
constexpr T value_or (U &&v) &&noexcept(std::is_nothrow_move_constructible_v< T > &&expected_detail::is_nothrow_convertible_v< U, T >)
 
template<class G = E>
constexpr E error_or (G &&v) const &noexcept(std::is_nothrow_copy_constructible_v< E > &&expected_detail::is_nothrow_convertible_v< G, E >)
 
template<class G = E>
constexpr E error_or (G &&v) &&noexcept(std::is_nothrow_move_constructible_v< E > &&expected_detail::is_nothrow_convertible_v< G, E >)
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, GE & > > * = nullptr>
constexpr auto and_then (F &&f) &
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, const GE & > > * = nullptr>
constexpr auto and_then (F &&f) const &
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, GE && > > * = nullptr>
constexpr auto and_then (F &&f) &&
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, const GE > > * = nullptr>
constexpr auto and_then (F &&f) const &&
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, UT & > > * = nullptr>
constexpr auto or_else (F &&f) &
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, const UT & > > * = nullptr>
constexpr auto or_else (F &&f) const &
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, UT && > > * = nullptr>
constexpr auto or_else (F &&f) &&
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, const UT > > * = nullptr>
constexpr auto or_else (F &&f) const &&
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, GE & > > * = nullptr>
constexpr auto transform (F &&f) &
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, const GE & > > * = nullptr>
constexpr auto transform (F &&f) const &
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, GE && > > * = nullptr>
constexpr auto transform (F &&f) &&
 
template<class F , class GE = E, std::enable_if_t< std::is_constructible_v< GE, const GE > > * = nullptr>
constexpr auto transform (F &&f) const &&
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, UT & > > * = nullptr>
constexpr auto transform_error (F &&f) &
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, const UT & > > * = nullptr>
constexpr auto transform_error (F &&f) const &
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, UT && > > * = nullptr>
constexpr auto transform_error (F &&f) &&
 
template<class F , class UT = T, std::enable_if_t< std::is_constructible_v< UT, const UT > > * = nullptr>
constexpr auto transform_error (F &&f) const &&
 

Friends

template<class T2 , class E2 >
constexpr std::enable_if_t< !std::is_void_v< T2 > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 > &&expected_detail::is_equality_result_convertible_to_bool_v< E, E2 >, bool > operator== (const expected &x, const expected< T2, E2 > &y) noexcept(expected_detail::is_nothrow_equality_result_convertible_to_bool_v< T, T2 > &&expected_detail::is_nothrow_equality_result_convertible_to_bool_v< E, E2 >)
 
template<class T2 , class E2 >
constexpr std::enable_if_t< !std::is_void_v< T2 > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 > &&expected_detail::is_equality_result_convertible_to_bool_v< E, E2 >, bool > operator!= (const expected &x, const expected< T2, E2 > &y) noexcept(noexcept(x==y))
 
template<class T2 >
constexpr std::enable_if_t< !expected_detail::is_specialization_v< T2, iceberg::expected > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 >, bool > operator== (const expected &x, const T2 &v) noexcept(expected_detail::is_nothrow_equality_result_convertible_to_bool_v< T, T2 >)
 
template<class T2 >
constexpr std::enable_if_t< !expected_detail::is_specialization_v< T2, iceberg::expected > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 >, bool > operator!= (const expected &x, const T2 &v) noexcept(noexcept(x==v))
 
template<class E2 >
constexpr std::enable_if_t< expected_detail::is_equality_result_convertible_to_bool_v< E, E2 >, bool > operator== (const expected &x, const unexpected< E2 > &e) noexcept(expected_detail::is_nothrow_equality_result_convertible_to_bool_v< E, E2 >)
 
template<class E2 >
constexpr std::enable_if_t< expected_detail::is_equality_result_convertible_to_bool_v< E, E2 >, bool > operator!= (const expected &x, const unexpected< E2 > &e) noexcept(noexcept(x==e))
 

Detailed Description

template<class T, class E>
class iceberg::expected< T, E >

An expected<T, E> object is an object that contains the storage for another object and manages the lifetime of this contained object T. Alternatively it could contain the storage for another unexpected object E. The contained object may not be initialized after the expected object has been initialized, and may not be destroyed before the expected object has been destroyed. The initialization state of the contained object is tracked by the expected object.


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