STX  1.0.0
List of all members
stx::Ok< T > Struct Template Reference

#include <option_result.h>

Detailed Description

template<typename T>
struct stx::Ok< T >

value-variant for Result<T, E> wrapping the contained successful value of type T

Note that Ok is only a value-forwarding type. An Ok<T> can only be constructed with an r-value. What does this mean?

For example, You can:

Result<vector<int>, int> a = Ok(vector{1, 2, 3, 4});

You can't:

vector<int> x {1, 2, 3, 4};
Result<vector<int>, int> a = Ok(x);

But, to explicitly make a take ownership, you will:

vector<int> x {1, 2, 3, 4};
Result<vector<int>, int> a = Ok(std::move(x));

Constexpr ?

C++ 17 and above

Member Typedef Documentation

◆ value_type

template<typename T>
using stx::Ok< T >::value_type = T

Constructor & Destructor Documentation

◆ Ok() [1/3]

template<typename T>
constexpr stx::Ok< T >::Ok ( T &&  value)
inlineexplicit

an Ok<T> can only be constructed with an r-value of type T

◆ Ok() [2/3]

template<typename T>
constexpr stx::Ok< T >::Ok ( Ok< T > &&  rhs)
default

◆ Ok() [3/3]

template<typename T>
constexpr stx::Ok< T >::Ok ( Ok< T > const &  )
default

◆ ~Ok()

template<typename T>
STX_CXX20_DESTRUCTOR_CONSTEXPR stx::Ok< T >::~Ok ( )
default

Member Function Documentation

◆ operator!=() [1/2]

template<typename T>
template<typename U >
constexpr bool stx::Ok< T >::operator!= ( Ok< U > const &  cmp) const
inline

◆ operator!=() [2/2]

template<typename T>
template<typename U >
constexpr bool stx::Ok< T >::operator!= ( Err< U > const &  ) const
inlinenoexcept

◆ operator=() [1/2]

template<typename T>
constexpr Ok& stx::Ok< T >::operator= ( Ok< T > &&  rhs)
default

◆ operator=() [2/2]

template<typename T>
constexpr Ok& stx::Ok< T >::operator= ( Ok< T > const &  )
default

◆ operator==() [1/2]

template<typename T>
template<typename U >
constexpr bool stx::Ok< T >::operator== ( Ok< U > const &  cmp) const
inline

◆ operator==() [2/2]

template<typename T>
template<typename U >
constexpr bool stx::Ok< T >::operator== ( Err< U > const &  ) const
inlinenoexcept

◆ value() [1/4]

template<typename T>
constexpr T const& stx::Ok< T >::value ( ) const &
inlinenoexcept

◆ value() [2/4]

template<typename T>
constexpr T& stx::Ok< T >::value ( ) &
inlinenoexcept

◆ value() [3/4]

template<typename T>
constexpr T const stx::Ok< T >::value ( ) const &&
inline

◆ value() [4/4]

template<typename T>
constexpr T stx::Ok< T >::value ( ) &&
inline

Friends And Related Function Documentation

◆ Result

template<typename T>
template<typename Tp , typename Er >
friend struct Result
friend

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