LibQuicR
quicr::Expected< void, E > Class Template Reference

void specialization that represents success by an empty optional. More...

#include <expected.h>

Public Member Functions

 Expected ()=default
 Constructs a successful result. More...
 
template<typename U >
 Expected (U &&value)
 Constructs an error result. More...
 
template<typename U >
requires std::is_convertible_v< U, E > Expected (Unexpected< U > &&unex)
 Constructs an error result from an unexpected value. More...
 
bool has_value () const noexcept
 
 operator bool () const noexcept
 
const E & error () const
 

Detailed Description

template<typename E>
class quicr::Expected< void, E >

void specialization that represents success by an empty optional.

Template Parameters
EError type.

Constructor & Destructor Documentation

◆ Expected() [1/3]

template<typename E >
quicr::Expected< void, E >::Expected ( )
default

Constructs a successful result.

◆ Expected() [2/3]

template<typename E >
template<typename U >
quicr::Expected< void, E >::Expected ( U &&  value)
inline

Constructs an error result.

Template Parameters
UType accepted by E.
Parameters
valueValue forwarded to the stored error.

◆ Expected() [3/3]

template<typename E >
template<typename U >
requires std::is_convertible_v<U, E> quicr::Expected< void, E >::Expected ( Unexpected< U > &&  unex)
inline

Constructs an error result from an unexpected value.

Template Parameters
UError source type convertible to E.
Parameters
unexWrapper whose error is copied into this result.

Member Function Documentation

◆ error()

template<typename E >
const E& quicr::Expected< void, E >::error ( ) const
inline
Returns
A reference to the stored error.
Exceptions
std::bad_optional_accessIf this object represents success.

◆ has_value()

template<typename E >
bool quicr::Expected< void, E >::has_value ( ) const
inlinenoexcept
Returns
true when no error is stored.

◆ operator bool()

template<typename E >
quicr::Expected< void, E >::operator bool ( ) const
inlineexplicitnoexcept
Returns
The same state reported by has_value().

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