libzypp  17.38.7
zyppng::expected< T, E > Class Template Reference

#include <zypp-core/ng/pipelines/expected.h>

Public Types

using value_type = T
 
using error_type = E
 

Public Member Functions

 ~expected ()
 
 expected (const T &v)
 
 expected (T &&v)
 
 expected (const unexpected< E > &err) noexcept
 
 expected (unexpected< E > &&err) noexcept
 
 expected (const expected &other)
 
 expected (expected &&other) noexcept
 
template<class G = E>
expectedoperator= (unexpected< G > other)
 
expectedoperator= (expected other)
 
template<class U = std::remove_cv_t<T>>
expectedoperator= (U &&v)
 
void swap (expected &other) noexcept
 
 operator bool () const
 
bool is_valid () const
 
T & get ()
 
const T & get () const
 
T & unwrap ()
 
const T & unwrap () const
 
T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
const T * operator-> () const
 
E & error ()
 
const E & error () const
 
template<typename F >
void visit (F f)
 

Static Public Member Functions

template<typename... ConsParams>
static expected success (ConsParams &&...params)
 
template<typename... ConsParams>
static expected error (ConsParams &&...params)
 

Protected Member Functions

 expected ()
 

Protected Attributes

union {
   T   m_value
 
   E   m_error
 
}; 
 
bool m_isValid
 

Detailed Description

template<typename T, typename E = std::exception_ptr>
class zyppng::expected< T, E >

Definition at line 56 of file expected.h.

Member Typedef Documentation

◆ value_type

template<typename T, typename E = std::exception_ptr>
using zyppng::expected< T, E >::value_type = T

Definition at line 71 of file expected.h.

◆ error_type

template<typename T, typename E = std::exception_ptr>
using zyppng::expected< T, E >::error_type = E

Definition at line 72 of file expected.h.

Constructor & Destructor Documentation

◆ expected() [1/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( )
inlineprotected

Definition at line 65 of file expected.h.

◆ ~expected()

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::~expected ( )
inline

Definition at line 74 of file expected.h.

◆ expected() [2/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( const T &  v)
inline

Definition at line 83 of file expected.h.

◆ expected() [3/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( T &&  v)
inline

Definition at line 88 of file expected.h.

◆ expected() [4/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( const unexpected< E > &  err)
inlinenoexcept

Definition at line 93 of file expected.h.

◆ expected() [5/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( unexpected< E > &&  err)
inlinenoexcept

Definition at line 98 of file expected.h.

◆ expected() [6/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( const expected< T, E > &  other)
inline

Definition at line 103 of file expected.h.

◆ expected() [7/7]

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::expected ( expected< T, E > &&  other)
inlinenoexcept

Definition at line 113 of file expected.h.

Member Function Documentation

◆ operator=() [1/3]

template<typename T, typename E = std::exception_ptr>
template<class G = E>
expected& zyppng::expected< T, E >::operator= ( unexpected< G >  other)
inline

Definition at line 124 of file expected.h.

◆ operator=() [2/3]

template<typename T, typename E = std::exception_ptr>
expected& zyppng::expected< T, E >::operator= ( expected< T, E >  other)
inline

Definition at line 130 of file expected.h.

◆ operator=() [3/3]

template<typename T, typename E = std::exception_ptr>
template<class U = std::remove_cv_t<T>>
expected& zyppng::expected< T, E >::operator= ( U &&  v)
inline

Definition at line 137 of file expected.h.

◆ swap()

template<typename T, typename E = std::exception_ptr>
void zyppng::expected< T, E >::swap ( expected< T, E > &  other)
inlinenoexcept

Definition at line 143 of file expected.h.

◆ success()

template<typename T, typename E = std::exception_ptr>
template<typename... ConsParams>
static expected zyppng::expected< T, E >::success ( ConsParams &&...  params)
inlinestatic

Definition at line 178 of file expected.h.

◆ error() [1/3]

template<typename T, typename E = std::exception_ptr>
template<typename... ConsParams>
static expected zyppng::expected< T, E >::error ( ConsParams &&...  params)
inlinestatic

Definition at line 189 of file expected.h.

◆ operator bool()

template<typename T, typename E = std::exception_ptr>
zyppng::expected< T, E >::operator bool ( ) const
inline

Definition at line 199 of file expected.h.

◆ is_valid()

template<typename T, typename E = std::exception_ptr>
bool zyppng::expected< T, E >::is_valid ( ) const
inline

Definition at line 204 of file expected.h.

◆ get() [1/2]

template<typename T, typename E = std::exception_ptr>
T& zyppng::expected< T, E >::get ( )
inline

Definition at line 215 of file expected.h.

◆ get() [2/2]

template<typename T, typename E = std::exception_ptr>
const T& zyppng::expected< T, E >::get ( ) const
inline

Definition at line 221 of file expected.h.

◆ unwrap() [1/2]

template<typename T, typename E = std::exception_ptr>
T& zyppng::expected< T, E >::unwrap ( )
inline

Unwraps the value if the expected is valid, otherwise throws an exception. If the Error type is std::exception_ptr the exception will be rethrown, otherwise the Error object is directly thrown as if calling:

expected<int,MyError> test = functionReturningError();
throw test.error();

Definition at line 236 of file expected.h.

◆ unwrap() [2/2]

template<typename T, typename E = std::exception_ptr>
const T& zyppng::expected< T, E >::unwrap ( ) const
inline

Definition at line 252 of file expected.h.

◆ operator*() [1/2]

template<typename T, typename E = std::exception_ptr>
T& zyppng::expected< T, E >::operator* ( )
inline

Definition at line 268 of file expected.h.

◆ operator*() [2/2]

template<typename T, typename E = std::exception_ptr>
const T& zyppng::expected< T, E >::operator* ( ) const
inline

Definition at line 273 of file expected.h.

◆ operator->() [1/2]

template<typename T, typename E = std::exception_ptr>
T* zyppng::expected< T, E >::operator-> ( )
inline

Definition at line 278 of file expected.h.

◆ operator->() [2/2]

template<typename T, typename E = std::exception_ptr>
const T* zyppng::expected< T, E >::operator-> ( ) const
inline

Definition at line 283 of file expected.h.

◆ error() [2/3]

template<typename T, typename E = std::exception_ptr>
E& zyppng::expected< T, E >::error ( )
inline

Definition at line 288 of file expected.h.

◆ error() [3/3]

template<typename T, typename E = std::exception_ptr>
const E& zyppng::expected< T, E >::error ( ) const
inline

Definition at line 294 of file expected.h.

◆ visit()

template<typename T, typename E = std::exception_ptr>
template<typename F >
void zyppng::expected< T, E >::visit ( f)
inline

Definition at line 303 of file expected.h.

Member Data Documentation

◆ m_value

template<typename T, typename E = std::exception_ptr>
T zyppng::expected< T, E >::m_value

Definition at line 59 of file expected.h.

◆ m_error

template<typename T, typename E = std::exception_ptr>
E zyppng::expected< T, E >::m_error

Definition at line 60 of file expected.h.

◆ @9

union { ... }

◆ m_isValid

template<typename T, typename E = std::exception_ptr>
bool zyppng::expected< T, E >::m_isValid
protected

Definition at line 63 of file expected.h.


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