libsshpp v0.1.7
Modern C++17 wrapper for libssh
Loading...
Searching...
No Matches
sshpp::Result< T > Class Template Reference

#include <result.hpp>

Public Types

using value_type = T
 
using error_type = ErrorInfo
 

Public Member Functions

 Result (T value)
 
 Result (ErrorInfo error)
 
 Result (const Result &)=default
 
 Result (Result &&) noexcept=default
 
Resultoperator= (const Result &)=default
 
Resultoperator= (Result &&) noexcept=default
 
 ~Result ()=default
 
bool has_value () const noexcept
 
 operator bool () const noexcept
 
T & value () &
 
const T & value () const &
 
T && value () &&
 
template<class U >
value_or (U &&fallback) const &
 
T * operator-> () noexcept
 
const T * operator-> () const noexcept
 
T & operator* () &noexcept
 
const T & operator* () const &noexcept
 
const ErrorInfoerror () const &noexcept
 
std::error_code code () const noexcept
 
void throw_if_error () const
 
template<class F >
auto and_then (F &&f) &&
 
template<class F >
auto transform (F &&f) &&
 
template<class F >
Result or_else (F &&f) &&
 

Detailed Description

template<class T>
class sshpp::Result< T >

C++17 backport of the subset of std::expected<T, ErrorInfo> this library commits to. Uses std::optional<T> for storage so T need not be default-constructible. See docs/design/03 ยง3.5.

Member Typedef Documentation

◆ value_type

template<class T >
using sshpp::Result< T >::value_type = T

◆ error_type

template<class T >
using sshpp::Result< T >::error_type = ErrorInfo

Constructor & Destructor Documentation

◆ Result() [1/4]

template<class T >
sshpp::Result< T >::Result ( value)
inline

◆ Result() [2/4]

template<class T >
sshpp::Result< T >::Result ( ErrorInfo  error)
inline

◆ Result() [3/4]

template<class T >
sshpp::Result< T >::Result ( const Result< T > &  )
default

◆ Result() [4/4]

template<class T >
sshpp::Result< T >::Result ( Result< T > &&  )
defaultnoexcept

◆ ~Result()

template<class T >
sshpp::Result< T >::~Result ( )
default

Member Function Documentation

◆ operator=() [1/2]

template<class T >
Result & sshpp::Result< T >::operator= ( const Result< T > &  )
default

◆ operator=() [2/2]

template<class T >
Result & sshpp::Result< T >::operator= ( Result< T > &&  )
defaultnoexcept

◆ has_value()

template<class T >
bool sshpp::Result< T >::has_value ( ) const
inlinenoexcept

◆ operator bool()

template<class T >
sshpp::Result< T >::operator bool ( ) const
inlineexplicitnoexcept

◆ value() [1/3]

template<class T >
T & sshpp::Result< T >::value ( ) &
inline

◆ value() [2/3]

template<class T >
const T & sshpp::Result< T >::value ( ) const &
inline

◆ value() [3/3]

template<class T >
T && sshpp::Result< T >::value ( ) &&
inline

◆ value_or()

template<class T >
template<class U >
T sshpp::Result< T >::value_or ( U &&  fallback) const &
inline

◆ operator->() [1/2]

template<class T >
T * sshpp::Result< T >::operator-> ( )
inlinenoexcept

◆ operator->() [2/2]

template<class T >
const T * sshpp::Result< T >::operator-> ( ) const
inlinenoexcept

◆ operator*() [1/2]

template<class T >
T & sshpp::Result< T >::operator* ( ) &
inlinenoexcept

◆ operator*() [2/2]

template<class T >
const T & sshpp::Result< T >::operator* ( ) const &
inlinenoexcept

◆ error()

template<class T >
const ErrorInfo & sshpp::Result< T >::error ( ) const &
inlinenoexcept

◆ code()

template<class T >
std::error_code sshpp::Result< T >::code ( ) const
inlinenoexcept

◆ throw_if_error()

template<class T >
void sshpp::Result< T >::throw_if_error ( ) const
inline

◆ and_then()

template<class T >
template<class F >
auto sshpp::Result< T >::and_then ( F &&  f) &&
inline

◆ transform()

template<class T >
template<class F >
auto sshpp::Result< T >::transform ( F &&  f) &&
inline

◆ or_else()

template<class T >
template<class F >
Result sshpp::Result< T >::or_else ( F &&  f) &&
inline

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