libzypp 17.37.10

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

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

## Public Types
using | value_type = T
using | error_type = E

## Public Member Functions
| ~expected ()
| expected (const expected &other)
| expected (expected &&other) noexcept
expected & | operator= (expected other)
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 27 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 42 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 43 of file expected.h.

## Constructor & Destructor Documentation

## ◆ expected() [1/3]

template<typename T, typename E = std::exception_ptr>

zyppng::expected< T, E >::expected | ( |  | ) |
| inline protected

Definition at line 36 of file expected.h.

## ◆ ~expected()

template<typename T, typename E = std::exception_ptr>

zyppng::expected< T, E >::~expected | ( |  | ) |
| inline

Definition at line 45 of file expected.h.

## ◆ expected() [2/3]

template<typename T, typename E = std::exception_ptr>

zyppng::expected< T, E >::expected | ( | const expected< T, E > & | other | ) |
| inline

Definition at line 54 of file expected.h.

## ◆ expected() [3/3]

template<typename T, typename E = std::exception_ptr>

zyppng::expected< T, E >::expected | ( | expected< T, E > && | other | ) |
| inline noexcept

Definition at line 64 of file expected.h.

## Member Function Documentation

## ◆ operator=()

template<typename T, typename E = std::exception_ptr>

expected & zyppng::expected< T, E >::operator= | ( | expected< T, E > | other | ) |
| inline

Definition at line 74 of file expected.h.

## ◆ swap()

template<typename T, typename E = std::exception_ptr>

void zyppng::expected< T, E >::swap | ( | expected< T, E > & | other | ) |
| inline noexcept

Definition at line 80 of file expected.h.

## ◆ success()

template<typename T, typename E = std::exception_ptr>
template<typename... ConsParams>

expected zyppng::expected< T, E >::success | ( | ConsParams &&... | params | ) |
| inline static

Definition at line 115 of file expected.h.

## ◆ error() [1/3]

template<typename T, typename E = std::exception_ptr>
template<typename... ConsParams>

expected zyppng::expected< T, E >::error | ( | ConsParams &&... | params | ) |
| inline static

Definition at line 126 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 136 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 141 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 152 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 158 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();
zyppng::expected::expected
expected()
Definition expected.h:36
zyppng::expected::error
static expected error(ConsParams &&...params)
Definition expected.h:126

Definition at line 173 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 189 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 205 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 210 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 215 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 220 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 225 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 231 of file expected.h.

## ◆ visit()

template<typename T, typename E = std::exception_ptr>
template<typename F>

void zyppng::expected< T, E >::visit | ( | F | f | ) |
| inline

Definition at line 240 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 30 of file expected.h.

## ◆ m_error

template<typename T, typename E = std::exception_ptr>

E zyppng::expected< T, E >::m_error

Definition at line 31 of file expected.h.

## ◆ [union]

union { ... } zyppng::expected< T, E >

## ◆ m_isValid

template<typename T, typename E = std::exception_ptr>

bool zyppng::expected< T, E >::m_isValid
| protected

Definition at line 34 of file expected.h.

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

- zypp-core/zyppng/pipelines/expected.h