Android-cuttlefish cvd tool
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
android::base::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<class U >
using rebind = expected< U, error_type >
 

Public Member Functions

constexpr expected ()=default
 
constexpr expected (const expected &rhs)=default
 
constexpr expected (expected &&rhs) noexcept=default
 
template<class U , class G _ENABLE_IF>
constexpr expected (const expected< U, G > &rhs)
 
template<class U , class G _ENABLE_IF>
constexpr expected (const expected< U, G > &rhs)
 
template<class U , class G _ENABLE_IF>
constexpr expected (expected< U, G > &&rhs)
 
template<class U , class G _ENABLE_IF>
constexpr expected (expected< U, G > &&rhs)
 
template<class U = T _ENABLE_IF( std::is_constructible_v<T, U&&> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<U>>, std::in_place_t> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && std::is_convertible_v<U&&, T> )>
constexpr expected (U &&v)
 
template<class U = T _ENABLE_IF( std::is_constructible_v<T, U&&> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<U>>, std::in_place_t> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_convertible_v<U&&, T> )>
constexpr expected (U &&v)
 
template<class G = E _ENABLE_IF( std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> )>
constexpr expected (const unexpected< G > &e)
 
template<class G = E _ENABLE_IF( std::is_constructible_v<E, const G&> && !std::is_convertible_v<const G&, E> )>
constexpr expected (const unexpected< G > &e)
 
template<class G = E _ENABLE_IF( std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> )>
constexpr expected (unexpected< G > &&e)
 
template<class G = E _ENABLE_IF( std::is_constructible_v<E, G&&> && !std::is_convertible_v<G&&, E> )>
constexpr expected (unexpected< G > &&e)
 
template<class... Args _ENABLE_IF>
constexpr expected (std::in_place_t, Args &&... args)
 
template<class U , class... Args _ENABLE_IF>
constexpr expected (std::in_place_t, std::initializer_list< U > il, Args &&... args)
 
template<class... Args _ENABLE_IF>
constexpr expected (unexpect_t, Args &&... args)
 
template<class U , class... Args _ENABLE_IF>
constexpr expected (unexpect_t, std::initializer_list< U > il, Args &&... args)
 
 ~expected ()=default
 
expectedoperator= (const expected &rhs)=default
 
expectedoperator= (expected &&rhs) noexcept(std::is_nothrow_move_assignable_v< T > &&std::is_nothrow_move_assignable_v< E >)=default
 
template<class U = T _ENABLE_IF( !std::is_void_v<T> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::conjunction_v<std::is_scalar<T>, std::is_same<T, std::decay_t<U>>> && std::is_constructible_v<T, U> && std::is_assignable_v<T&, U> && std::is_nothrow_move_constructible_v<E>)>
expectedoperator= (U &&rhs)
 
template<class G = E>
expectedoperator= (const unexpected< G > &rhs)
 
template<class G = E _ENABLE_IF( std::is_nothrow_move_constructible_v<G> && std::is_move_assignable_v<G> )>
expectedoperator= (unexpected< G > &&rhs)
 
template<class... Args _ENABLE_IF>
T & emplace (Args &&... args)
 
template<class U , class... Args _ENABLE_IF>
T & emplace (std::initializer_list< U > il, Args &&... args)
 
template<typename U = T, typename = std::enable_if_t<( std::is_swappable_v<U> && std::is_swappable_v<E> && (std::is_move_constructible_v<U> || std::is_move_constructible_v<E>))>>
void 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
 
constexpr T * operator-> ()
 
constexpr const T & operator* () const &
 
constexpr T & operator* () &
 
constexpr const T && operator* () const &&
 
constexpr T && operator* () &&
 
constexpr bool has_value () const noexcept
 
constexpr bool ok () const noexcept
 
constexpr const T & value () const &
 
constexpr T & value () &
 
constexpr const T && value () const &&
 
constexpr T && value () &&
 
constexpr const E & error () const &
 
constexpr E & error () &
 
constexpr const E && error () const &&
 
constexpr E && error () &&
 
template<class U _ENABLE_IF>
constexpr T value_or (U &&v) const &
 
template<class U _ENABLE_IF>
constexpr T value_or (U &&v) &&
 

Private Attributes

std::variant< value_type, unexpected_typevar_
 

Friends

template<class T1 , class E1 , class T2 , class E2 >
constexpr bool operator== (const expected< T1, E1 > &x, const expected< T2, E2 > &y)
 
template<class T1 , class E1 , class T2 , class E2 >
constexpr bool operator!= (const expected< T1, E1 > &x, const expected< T2, E2 > &y)
 
template<class T1 , class E1 , class E2 >
constexpr bool operator== (const expected< T1, E1 > &, const unexpected< E2 > &)
 
template<class T1 , class E1 , class E2 >
constexpr bool operator== (const unexpected< E2 > &, const expected< T1, E1 > &)
 
template<class T1 , class E1 , class E2 >
constexpr bool operator!= (const expected< T1, E1 > &, const unexpected< E2 > &)
 
template<class T1 , class E1 , class E2 >
constexpr bool operator!= (const unexpected< E2 > &, const expected< T1, E1 > &)
 
template<class T1 , class E1 >
void swap (expected< T1, E1 > &x, expected< T1, E1 > &y) noexcept(noexcept(x.swap(y)))
 

Member Typedef Documentation

◆ error_type

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

◆ rebind

template<class T , class E >
template<class U >
using android::base::expected< T, E >::rebind = expected<U, error_type>

◆ unexpected_type

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

◆ value_type

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

Constructor & Destructor Documentation

◆ expected() [1/17]

template<class T , class E >
constexpr android::base::expected< T, E >::expected ( )
constexprdefault

◆ expected() [2/17]

template<class T , class E >
constexpr android::base::expected< T, E >::expected ( const expected< T, E > &  rhs)
constexprdefault

◆ expected() [3/17]

template<class T , class E >
constexpr android::base::expected< T, E >::expected ( expected< T, E > &&  rhs)
constexprdefaultnoexcept

◆ expected() [4/17]

template<class T , class E >
template<class U , class G _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( const expected< U, G > &  rhs)
inlineconstexpr

◆ expected() [5/17]

template<class T , class E >
template<class U , class G _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( const expected< U, G > &  rhs)
inlineexplicitconstexpr

◆ expected() [6/17]

template<class T , class E >
template<class U , class G _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( expected< U, G > &&  rhs)
inlineconstexpr

◆ expected() [7/17]

template<class T , class E >
template<class U , class G _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( expected< U, G > &&  rhs)
inlineexplicitconstexpr

◆ expected() [8/17]

template<class T , class E >
template<class U = T _ENABLE_IF( std::is_constructible_v<T, U&&> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<U>>, std::in_place_t> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && std::is_convertible_v<U&&, T> )>
constexpr android::base::expected< T, E >::expected ( U &&  v)
inlineconstexpr

◆ expected() [9/17]

template<class T , class E >
template<class U = T _ENABLE_IF( std::is_constructible_v<T, U&&> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<U>>, std::in_place_t> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::is_convertible_v<U&&, T> )>
constexpr android::base::expected< T, E >::expected ( U &&  v)
inlineexplicitconstexpr

◆ expected() [10/17]

template<class T , class E >
template<class G = E _ENABLE_IF( std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> )>
constexpr android::base::expected< T, E >::expected ( const unexpected< G > &  e)
inlineconstexpr

◆ expected() [11/17]

template<class T , class E >
template<class G = E _ENABLE_IF( std::is_constructible_v<E, const G&> && !std::is_convertible_v<const G&, E> )>
constexpr android::base::expected< T, E >::expected ( const unexpected< G > &  e)
inlineexplicitconstexpr

◆ expected() [12/17]

template<class T , class E >
template<class G = E _ENABLE_IF( std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> )>
constexpr android::base::expected< T, E >::expected ( unexpected< G > &&  e)
inlineconstexpr

◆ expected() [13/17]

template<class T , class E >
template<class G = E _ENABLE_IF( std::is_constructible_v<E, G&&> && !std::is_convertible_v<G&&, E> )>
constexpr android::base::expected< T, E >::expected ( unexpected< G > &&  e)
inlineexplicitconstexpr

◆ expected() [14/17]

template<class T , class E >
template<class... Args _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( std::in_place_t  ,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [15/17]

template<class T , class E >
template<class U , class... Args _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( std::in_place_t  ,
std::initializer_list< U >  il,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [16/17]

template<class T , class E >
template<class... Args _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( unexpect_t  ,
Args &&...  args 
)
inlineexplicitconstexpr

◆ expected() [17/17]

template<class T , class E >
template<class U , class... Args _ENABLE_IF>
constexpr android::base::expected< T, E >::expected ( unexpect_t  ,
std::initializer_list< U >  il,
Args &&...  args 
)
inlineexplicitconstexpr

◆ ~expected()

template<class T , class E >
android::base::expected< T, E >::~expected ( )
default

Member Function Documentation

◆ emplace() [1/2]

template<class T , class E >
template<class... Args _ENABLE_IF>
T & android::base::expected< T, E >::emplace ( Args &&...  args)
inline

◆ emplace() [2/2]

template<class T , class E >
template<class U , class... Args _ENABLE_IF>
T & android::base::expected< T, E >::emplace ( std::initializer_list< U >  il,
Args &&...  args 
)
inline

◆ error() [1/4]

template<class T , class E >
constexpr E & android::base::expected< T, E >::error ( ) &
inlineconstexpr

◆ error() [2/4]

template<class T , class E >
constexpr E && android::base::expected< T, E >::error ( ) &&
inlineconstexpr

◆ error() [3/4]

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

◆ error() [4/4]

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

◆ has_value()

template<class T , class E >
constexpr bool android::base::expected< T, E >::has_value ( ) const
inlineconstexprnoexcept

◆ ok()

template<class T , class E >
constexpr bool android::base::expected< T, E >::ok ( ) const
inlineconstexprnoexcept

◆ operator*() [1/4]

template<class T , class E >
constexpr T & android::base::expected< T, E >::operator* ( ) &
inlineconstexpr

◆ operator*() [2/4]

template<class T , class E >
constexpr T && android::base::expected< T, E >::operator* ( ) &&
inlineconstexpr

◆ operator*() [3/4]

template<class T , class E >
constexpr const T & android::base::expected< T, E >::operator* ( ) const &
inlineconstexpr

◆ operator*() [4/4]

template<class T , class E >
constexpr const T && android::base::expected< T, E >::operator* ( ) const &&
inlineconstexpr

◆ operator->() [1/2]

template<class T , class E >
constexpr T * android::base::expected< T, E >::operator-> ( )
inlineconstexpr

◆ operator->() [2/2]

template<class T , class E >
constexpr const T * android::base::expected< T, E >::operator-> ( ) const
inlineconstexpr

◆ operator=() [1/5]

template<class T , class E >
expected & android::base::expected< T, E >::operator= ( const expected< T, E > &  rhs)
default

◆ operator=() [2/5]

template<class T , class E >
template<class G = E>
expected & android::base::expected< T, E >::operator= ( const unexpected< G > &  rhs)
inline

◆ operator=() [3/5]

template<class T , class E >
expected & android::base::expected< T, E >::operator= ( expected< T, E > &&  rhs) &&
defaultnoexcept

◆ operator=() [4/5]

template<class T , class E >
template<class U = T _ENABLE_IF( !std::is_void_v<T> && !std::is_same_v<expected<T, E>, std::remove_cv_t<std::remove_reference_t<U>>> && !std::conjunction_v<std::is_scalar<T>, std::is_same<T, std::decay_t<U>>> && std::is_constructible_v<T, U> && std::is_assignable_v<T&, U> && std::is_nothrow_move_constructible_v<E>)>
expected & android::base::expected< T, E >::operator= ( U &&  rhs)
inline

◆ operator=() [5/5]

template<class T , class E >
template<class G = E _ENABLE_IF( std::is_nothrow_move_constructible_v<G> && std::is_move_assignable_v<G> )>
expected & android::base::expected< T, E >::operator= ( unexpected< G > &&  rhs)
inline

◆ swap()

template<class T , class E >
template<typename U = T, typename = std::enable_if_t<( std::is_swappable_v<U> && std::is_swappable_v<E> && (std::is_move_constructible_v<U> || std::is_move_constructible_v<E>))>>
void android::base::expected< T, E >::swap ( expected< T, E > &  rhs)
inlinenoexcept

◆ value() [1/4]

template<class T , class E >
constexpr T & android::base::expected< T, E >::value ( ) &
inlineconstexpr

◆ value() [2/4]

template<class T , class E >
constexpr T && android::base::expected< T, E >::value ( ) &&
inlineconstexpr

◆ value() [3/4]

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

◆ value() [4/4]

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

◆ value_or() [1/2]

template<class T , class E >
template<class U _ENABLE_IF>
constexpr T android::base::expected< T, E >::value_or ( U &&  v) &&
inlineconstexpr

◆ value_or() [2/2]

template<class T , class E >
template<class U _ENABLE_IF>
constexpr T android::base::expected< T, E >::value_or ( U &&  v) const &
inlineconstexpr

Friends And Related Function Documentation

◆ operator!= [1/3]

template<class T , class E >
template<class T1 , class E1 , class E2 >
constexpr bool operator!= ( const expected< T1, E1 > &  x,
const unexpected< E2 > &  y 
)
friend

◆ operator!= [2/3]

template<class T , class E >
template<class T1 , class E1 , class T2 , class E2 >
constexpr bool operator!= ( const expected< T1, E1 > &  x,
const expected< T2, E2 > &  y 
)
friend

◆ operator!= [3/3]

template<class T , class E >
template<class T1 , class E1 , class E2 >
constexpr bool operator!= ( const unexpected< E2 > &  x,
const expected< T1, E1 > &  y 
)
friend

◆ operator== [1/3]

template<class T , class E >
template<class T1 , class E1 , class E2 >
constexpr bool operator== ( const expected< T1, E1 > &  x,
const unexpected< E2 > &  y 
)
friend

◆ operator== [2/3]

template<class T , class E >
template<class T1 , class E1 , class T2 , class E2 >
constexpr bool operator== ( const expected< T1, E1 > &  x,
const expected< T2, E2 > &  y 
)
friend

◆ operator== [3/3]

template<class T , class E >
template<class T1 , class E1 , class E2 >
constexpr bool operator== ( const unexpected< E2 > &  x,
const expected< T1, E1 > &  y 
)
friend

◆ swap

template<class T , class E >
template<class T1 , class E1 >
void swap ( expected< T1, E1 > &  x,
expected< T1, E1 > &  y 
)
friend

Member Data Documentation

◆ var_

template<class T , class E >
std::variant<value_type, unexpected_type> android::base::expected< T, E >::var_
private

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