TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::Result< T > Class Template Reference

A value, or the Error saying why there is none. More...

#include <gui_core/gui_result.h>

Public Member Functions

 Result (T value)
 Implicit from a value or an Error, so functions can return either.
 Result (Error error)
bool HasValue () const
 True when it holds the value; same as the bool conversion.
 operator bool () const
T ValueOr (T fallback) const
 A copy of the value, or fallback when there is none.
const Error & GetError () const
 The error; only valid when !HasValue().
T & Value ()
 The value; only valid when HasValue() (std::get throws otherwise).
const T & Value () const
 The value; only valid when HasValue() (std::get throws otherwise).
T & operator* ()
 The value; only valid when HasValue() (std::get throws otherwise).
const T & operator* () const
 The value; only valid when HasValue() (std::get throws otherwise).
T * operator-> ()
 The value; only valid when HasValue() (std::get throws otherwise).
const T * operator-> () const
 The value; only valid when HasValue() (std::get throws otherwise).

Detailed Description

template<class T>
class tachyon::Result< T >

A value, or the Error saying why there is none.

True when it holds the value:

if (auto image = LoadImage(path)) Use(*image); else Log(image.GetError().message); 
Examples
controls/controls.cpp, custom_theme/custom_theme.cpp, docking/docking.cpp, hello_world/hello_world.cpp, and host_device/host_device.cpp.

Member Function Documentation

◆ HasValue()

template<class T>
bool tachyon::Result< T >::HasValue ( ) const
inline

True when it holds the value; same as the bool conversion.

◆ operator bool()

template<class T>
tachyon::Result< T >::operator bool ( ) const
inlineexplicit

◆ Value() [1/2]

template<class T>
T & tachyon::Result< T >::Value ( )
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ Value() [2/2]

template<class T>
const T & tachyon::Result< T >::Value ( ) const
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ operator*() [1/2]

template<class T>
T & tachyon::Result< T >::operator* ( )
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ operator*() [2/2]

template<class T>
const T & tachyon::Result< T >::operator* ( ) const
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ operator->() [1/2]

template<class T>
T * tachyon::Result< T >::operator-> ( )
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ operator->() [2/2]

template<class T>
const T * tachyon::Result< T >::operator-> ( ) const
inline

The value; only valid when HasValue() (std::get throws otherwise).

  • and -> do the same.

◆ ValueOr()

template<class T>
T tachyon::Result< T >::ValueOr ( T fallback) const
inline

A copy of the value, or fallback when there is none.

◆ GetError()

template<class T>
const Error & tachyon::Result< T >::GetError ( ) const
inline

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