MySQL 9.1.0
Source Code Documentation
stdx::expected< T, E > Class Template Reference

#include <expected.h>

Public Types

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

Public Member Functions

constexpr expected () noexcept(std::is_nothrow_default_constructible_v< T >)
 
constexpr expected (const expected &other)=default
 
constexpr expected (const expected &other) noexcept((std::is_nothrow_copy_constructible_v< T > &&std::is_nothrow_copy_constructible_v< E >))
 
constexpr expected (expected &&other)=default
 
constexpr expected (expected &&other) noexcept((std::is_nothrow_move_constructible_v< E > &&std::is_nothrow_move_constructible_v< T >))
 
template<class U , class G , class UF = std::add_lvalue_reference_t<const U>, class GF = const G &>
constexpr explicit (constructor_is_explicit< UF, GF >) expected(const expected< U
 
template<class U , class G , class UF = U, class GF = G>
constexpr explicit (constructor_is_explicit< UF, GF >) expected(expected< U
 
template<class U = T>
requires can_construct_from_value_type<U>
constexpr explicit (!std::is_convertible_v< U, T >) expected(U &&val)
 
template<class G >
requires std::is_constructible_v<E, const G &>
constexpr explicit (!std::is_convertible_v< const G &, E >) expected(const unexpected< G > &err)
 
template<class G >
requires std::is_constructible_v<E, G>
constexpr explicit (!std::is_convertible_v< G, E >) expected(unexpected< G > &&err)
 
template<class... Args>
requires std::is_constructible_v<T, Args...>
constexpr expected (std::in_place_t, Args &&...args)
 
template<class U , class... Args>
requires std::is_constructible_v<T, std::initializer_list<U> &, Args...>
constexpr expected (std::in_place_t, std::initializer_list< U > il, Args &&...args)
 
template<class... Args>
requires std::is_constructible_v<E, Args &&...>
constexpr expected (stdx::unexpect_t, Args &&...args)
 
template<class U , class... Args>
requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
constexpr expected (stdx::unexpect_t, std::initializer_list< U > il, Args &&...args)
 
constexpr expectedoperator= (expected const &other)
 
constexpr expectedoperator= (expected &&other)
 
template<class U = T>
requires ((!std::is_same_v<expected<T, E>, std::remove_cvref_t<U>> && // !impl::is_unexpected<std::remove_cvref_t<U>> && // 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>)))
constexpr expectedoperator= (U &&val)
 
template<class G , class GF = const G &>
requires ((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>)))
constexpr expectedoperator= (const unexpected< G > &other)
 
template<class G , class GF = G>
requires ((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>)))
constexpr expectedoperator= (unexpected< G > &&other)
 
constexpr ~expected ()
 
template<class... Args>
requires (std::is_nothrow_constructible_v<T, Args...>)
constexpr T & emplace (Args &&...args) noexcept
 
template<class U , class... Args>
requires ( std::is_nothrow_constructible_v<T, std::initializer_list<U> &, Args...>)
constexpr T & emplace (std::initializer_list< U > il, Args &&...args) noexcept
 
constexpr void swap (expected &other) noexcept((std::is_nothrow_move_constructible_v< T > &&//std::is_nothrow_move_constructible_v< E > &&//std::is_nothrow_swappable_v< T > &&//std::is_nothrow_swappable_v< E >))
 
constexpr bool has_value () const
 
constexpr operator bool () const noexcept
 
constexpr value_typevalue () &
 
constexpr const value_typevalue () const &
 
constexpr value_type && value () &&
 
constexpr const value_type && value () const &&
 
constexpr const value_typeoperator-> () const noexcept
 
constexpr value_typeoperator-> () noexcept
 
constexpr const value_typeoperator* () const &noexcept
 
constexpr value_typeoperator* () &noexcept
 
constexpr const value_type && operator* () const &&noexcept
 
constexpr value_type && operator* () &&noexcept
 
template<class U >
constexpr value_type value_or (U &&v) const &
 
template<class U >
constexpr value_type value_or (U &&v) &&
 
constexpr const error_typeerror () const &
 
constexpr const error_type && error () const &&
 
constexpr error_typeerror () &
 
constexpr error_type && error () &&
 
template<class Func >
constexpr auto and_then (Func &&func) &
 
template<class Func >
constexpr auto and_then (Func &&func) &&
 
template<class Func >
constexpr auto and_then (Func &&func) const &
 
template<class Func >
constexpr auto and_then (Func &&func) const &&
 
template<class Func >
constexpr auto or_else (Func &&func) &
 
template<class Func >
constexpr auto or_else (Func &&func) &&
 
template<class Func >
constexpr auto or_else (Func &&func) const &
 
template<class Func >
constexpr auto or_else (Func &&func) const &&
 
template<class Func >
constexpr auto transform (Func &&func) &
 
template<class Func >
constexpr auto transform (Func &&func) &&
 
template<class Func >
constexpr auto transform (Func &&func) const &
 
template<class Func >
constexpr auto transform (Func &&func) const &&
 

Public Attributes

constexpr G & rhs: has_value_{rhs.has_value()} { if (rhs.has_value()) { std::construct_at(std::addressof(val_)
 
constexpr G std::forward< UF > rhs
 
 else
 
constexpr G && rhs: has_value_{rhs.has_value()} { if (rhs.has_value()) { std::construct_at(std::addressof(val_)
 
val_
 
unex_
 

Static Public Attributes

template<class UF , class GF >
static constexpr bool constructor_is_explicit
 
template<class U , class G , class UF , class GF >
static constexpr bool can_value_convert_construct
 
template<class U >
static constexpr bool can_construct_from_value_type
 

Private Member Functions

template<class U >
void assign_val (U &&u)
 
template<class U >
void assign_unex (U &&u)
 

Private Attributes

union {
   T   val_
 
   E   unex_
 
}; 
 
bool has_value_
 

Friends

template<class T2 , class E2 >
requires (!std::is_void_v<T2>)
constexpr friend bool operator== (const expected &lhs, const stdx::expected< T2, E2 > &rhs)
 
template<class T2 >
requires (!impl::is_expected<T2>)
constexpr friend bool operator== (const expected &lhs, const T2 &rhs)
 
template<class E2 >
constexpr friend bool operator== (const expected &lhs, const unexpected< E2 > &rhs)
 

Member Typedef Documentation

◆ error_type

template<class T , class E >
using stdx::expected< T, E >::error_type = E

◆ rebind

template<class T , class E >
template<typename U >
using stdx::expected< T, E >::rebind = expected<U, error_type>

◆ unexpected_type

template<class T , class E >
using stdx::expected< T, E >::unexpected_type = unexpected<E>

◆ value_type

template<class T , class E >
using stdx::expected< T, E >::value_type = T

Constructor & Destructor Documentation

◆ expected() [1/9]

template<class T , class E >
constexpr stdx::expected< T, E >::expected ( )
inlineconstexprnoexcept

◆ expected() [2/9]

template<class T , class E >
constexpr stdx::expected< T, E >::expected ( const expected< T, E > &  other)
constexprdefault

◆ expected() [3/9]

template<class T , class E >
constexpr stdx::expected< T, E >::expected ( const expected< T, E > &  other)
inlineconstexprnoexcept

◆ expected() [4/9]

template<class T , class E >
constexpr stdx::expected< T, E >::expected ( expected< T, E > &&  other)
constexprdefault

◆ expected() [5/9]

template<class T , class E >
constexpr stdx::expected< T, E >::expected ( expected< T, E > &&  other)
inlineconstexprnoexcept

◆ expected() [6/9]

template<class T , class E >
template<class... Args>
requires std::is_constructible_v<T, Args...>
constexpr stdx::expected< T, E >::expected ( std::in_place_t  ,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [7/9]

template<class T , class E >
template<class U , class... Args>
requires std::is_constructible_v<T, std::initializer_list<U> &, Args...>
constexpr stdx::expected< T, E >::expected ( std::in_place_t  ,
std::initializer_list< U il,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [8/9]

template<class T , class E >
template<class... Args>
requires std::is_constructible_v<E, Args &&...>
constexpr stdx::expected< T, E >::expected ( stdx::unexpect_t  ,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [9/9]

template<class T , class E >
template<class U , class... Args>
requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
constexpr stdx::expected< T, E >::expected ( stdx::unexpect_t  ,
std::initializer_list< U il,
Args &&...  args 
)
inlineexplicitconstexpr

◆ ~expected()

template<class T , class E >
constexpr stdx::expected< T, E >::~expected ( )
inlineconstexpr

Member Function Documentation

◆ and_then() [1/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::and_then ( Func &&  func) &
inlineconstexpr

◆ and_then() [2/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::and_then ( Func &&  func) &&
inlineconstexpr

◆ and_then() [3/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::and_then ( Func &&  func) const &
inlineconstexpr

◆ and_then() [4/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::and_then ( Func &&  func) const &&
inlineconstexpr

◆ assign_unex()

template<class T , class E >
template<class U >
void stdx::expected< T, E >::assign_unex ( U &&  u)
inlineprivate

◆ assign_val()

template<class T , class E >
template<class U >
void stdx::expected< T, E >::assign_val ( U &&  u)
inlineprivate

◆ emplace() [1/2]

template<class T , class E >
template<class... Args>
requires (std::is_nothrow_constructible_v<T, Args...>)
constexpr T & stdx::expected< T, E >::emplace ( Args &&...  args)
inlineconstexprnoexcept

◆ emplace() [2/2]

template<class T , class E >
template<class U , class... Args>
requires ( std::is_nothrow_constructible_v<T, std::initializer_list<U> &, Args...>)
constexpr T & stdx::expected< T, E >::emplace ( std::initializer_list< U il,
Args &&...  args 
)
inlineconstexprnoexcept

◆ error() [1/4]

template<class T , class E >
constexpr error_type & stdx::expected< T, E >::error ( ) &
inlineconstexpr

◆ error() [2/4]

template<class T , class E >
constexpr error_type && stdx::expected< T, E >::error ( ) &&
inlineconstexpr

◆ error() [3/4]

template<class T , class E >
constexpr const error_type & stdx::expected< T, E >::error ( ) const &
inlineconstexpr

◆ error() [4/4]

template<class T , class E >
constexpr const error_type && stdx::expected< T, E >::error ( ) const &&
inlineconstexpr

◆ explicit() [1/5]

template<class T , class E >
template<class G >
requires std::is_constructible_v<E, const G &>
constexpr stdx::expected< T, E >::explicit ( !std::is_convertible_v< const G &, E >  ) const &
inlineconstexpr

◆ explicit() [2/5]

template<class T , class E >
template<class G >
requires std::is_constructible_v<E, G>
constexpr stdx::expected< T, E >::explicit ( !std::is_convertible_v< G, E >  ) &&
inlineconstexpr

◆ explicit() [3/5]

template<class T , class E >
template<class U = T>
requires can_construct_from_value_type<U>
constexpr stdx::expected< T, E >::explicit ( !std::is_convertible_v< U, T >  ) &&
inlineconstexpr

◆ explicit() [4/5]

template<class T , class E >
template<class U , class G , class UF = std::add_lvalue_reference_t<const U>, class GF = const G &>
constexpr stdx::expected< T, E >::explicit ( constructor_is_explicit< UF, GF >  ) const
constexpr

◆ explicit() [5/5]

template<class T , class E >
template<class U , class G , class UF = U, class GF = G>
constexpr stdx::expected< T, E >::explicit ( constructor_is_explicit< UF, GF >  )
constexpr

◆ has_value()

template<class T , class E >
constexpr bool stdx::expected< T, E >::has_value ( ) const
inlineconstexpr

◆ operator bool()

template<class T , class E >
constexpr stdx::expected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

◆ operator*() [1/4]

template<class T , class E >
constexpr value_type && stdx::expected< T, E >::operator* ( ) &&
inlineconstexprnoexcept

◆ operator*() [2/4]

template<class T , class E >
constexpr value_type & stdx::expected< T, E >::operator* ( ) &
inlineconstexprnoexcept

◆ operator*() [3/4]

template<class T , class E >
constexpr const value_type && stdx::expected< T, E >::operator* ( ) const &&
inlineconstexprnoexcept

◆ operator*() [4/4]

template<class T , class E >
constexpr const value_type & stdx::expected< T, E >::operator* ( ) const &
inlineconstexprnoexcept

◆ operator->() [1/2]

template<class T , class E >
constexpr const value_type * stdx::expected< T, E >::operator-> ( ) const
inlineconstexprnoexcept

◆ operator->() [2/2]

template<class T , class E >
constexpr value_type * stdx::expected< T, E >::operator-> ( )
inlineconstexprnoexcept

◆ operator=() [1/5]

template<class T , class E >
template<class G , class GF = const G &>
requires ((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>)))
constexpr expected & stdx::expected< T, E >::operator= ( const unexpected< G > &  other)
inlineconstexpr

◆ operator=() [2/5]

template<class T , class E >
constexpr expected & stdx::expected< T, E >::operator= ( expected< T, E > &&  other)
inlineconstexpr

◆ operator=() [3/5]

template<class T , class E >
constexpr expected & stdx::expected< T, E >::operator= ( expected< T, E > const &  other)
inlineconstexpr

◆ operator=() [4/5]

template<class T , class E >
template<class U = T>
requires ((!std::is_same_v<expected<T, E>, std::remove_cvref_t<U>> && // !impl::is_unexpected<std::remove_cvref_t<U>> && // 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>)))
constexpr expected & stdx::expected< T, E >::operator= ( U &&  val)
inlineconstexpr

◆ operator=() [5/5]

template<class T , class E >
template<class G , class GF = G>
requires ((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>)))
constexpr expected & stdx::expected< T, E >::operator= ( unexpected< G > &&  other)
inlineconstexpr

◆ or_else() [1/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::or_else ( Func &&  func) &
inlineconstexpr

◆ or_else() [2/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::or_else ( Func &&  func) &&
inlineconstexpr

◆ or_else() [3/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::or_else ( Func &&  func) const &
inlineconstexpr

◆ or_else() [4/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::or_else ( Func &&  func) const &&
inlineconstexpr

◆ swap()

template<class T , class E >
constexpr void stdx::expected< T, E >::swap ( expected< T, E > &  other)
inlineconstexprnoexcept

◆ transform() [1/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::transform ( Func &&  func) &
inlineconstexpr

◆ transform() [2/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::transform ( Func &&  func) &&
inlineconstexpr

◆ transform() [3/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::transform ( Func &&  func) const &
inlineconstexpr

◆ transform() [4/4]

template<class T , class E >
template<class Func >
constexpr auto stdx::expected< T, E >::transform ( Func &&  func) const &&
inlineconstexpr

◆ value() [1/4]

template<class T , class E >
constexpr value_type & stdx::expected< T, E >::value ( ) &
inlineconstexpr

◆ value() [2/4]

template<class T , class E >
constexpr value_type && stdx::expected< T, E >::value ( ) &&
inlineconstexpr

◆ value() [3/4]

template<class T , class E >
constexpr const value_type & stdx::expected< T, E >::value ( ) const &
inlineconstexpr

◆ value() [4/4]

template<class T , class E >
constexpr const value_type && stdx::expected< T, E >::value ( ) const &&
inlineconstexpr

◆ value_or() [1/2]

template<class T , class E >
template<class U >
constexpr value_type stdx::expected< T, E >::value_or ( U &&  v) &&
inlineconstexpr

◆ value_or() [2/2]

template<class T , class E >
template<class U >
constexpr value_type stdx::expected< T, E >::value_or ( U &&  v) const &
inlineconstexpr

Friends And Related Function Documentation

◆ operator== [1/3]

template<class T , class E >
template<class T2 , class E2 >
requires (!std::is_void_v<T2>)
constexpr friend bool operator== ( const expected< T, E > &  lhs,
const stdx::expected< T2, E2 > &  rhs 
)
friend

◆ operator== [2/3]

template<class T , class E >
template<class T2 >
requires (!impl::is_expected<T2>)
constexpr friend bool operator== ( const expected< T, E > &  lhs,
const T2 &  rhs 
)
friend

◆ operator== [3/3]

template<class T , class E >
template<class E2 >
constexpr friend bool operator== ( const expected< T, E > &  lhs,
const unexpected< E2 > &  rhs 
)
friend

Member Data Documentation

◆ 

union { ... } stdx::expected< T, E >::@32

◆ can_construct_from_value_type

template<class T , class E >
template<class U >
constexpr bool stdx::expected< T, E >::can_construct_from_value_type
staticconstexpr
Initial value:
=
!std::is_same_v<std::in_place_t, std::remove_cvref_t<U>> &&
!std::is_same_v<expected, std::remove_cvref_t<U>> &&
std::is_constructible_v<T, U> &&
!impl::is_unexpected<std::remove_cvref_t<U>> &&
!impl::is_expected<std::remove_cvref_t<T>>

◆ can_value_convert_construct

template<class T , class E >
template<class U , class G , class UF , class GF >
constexpr bool stdx::expected< T, E >::can_value_convert_construct
staticconstexpr
Initial value:
=
(std::is_constructible_v<T, UF> &&
std::is_constructible_v<E, GF> &&
!std::is_constructible_v<T, expected<U, G> &> &&
!std::is_constructible_v<T, expected<U, G>> &&
!std::is_constructible_v<T, const expected<U, G> &> &&
!std::is_constructible_v<T, const expected<U, G>> &&
!std::is_convertible_v<expected<U, G> &, T> &&
!std::is_convertible_v<expected<U, G>, T> &&
!std::is_convertible_v<const expected<U, G> &, T> &&
!std::is_convertible_v<const expected<U, G>, T> &&
!std::is_constructible_v<unexpected<E>, expected<U, G> &> &&
!std::is_constructible_v<unexpected<E>, expected<U, G>> &&
!std::is_constructible_v<unexpected<E>, const expected<U, G> &> &&
!std::is_constructible_v<unexpected<E>, const expected<U, G>>)

◆ constructor_is_explicit

template<class T , class E >
template<class UF , class GF >
constexpr bool stdx::expected< T, E >::constructor_is_explicit
staticconstexpr
Initial value:
=
!std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>

◆ else

template<class T , class E >
stdx::expected< T, E >::else
Initial value:
{
std::construct_at(std::addressof(unex_), std::forward<GF>(rhs.error()))
constexpr G & rhs
Definition: expected.h:377
E unex_
Definition: expected.h:891

◆ has_value_

template<class T , class E >
bool stdx::expected< T, E >::has_value_
private

◆ rhs [1/3]

template<class T , class E >
constexpr G std::forward< UF > stdx::expected< T, E >::rhs

◆ rhs [2/3]

template<class T , class E >
constexpr G std::forward<UF> stdx::expected< T, E >::rhs

◆ rhs [3/3]

template<class T , class E >
constexpr G&& stdx::expected< T, E >::rhs

◆ unex_

template<class T , class E >
E stdx::expected< T, E >::unex_

◆ val_

template<class T , class E >
T stdx::expected< T, E >::val_

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