Octane API Client
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
octane::Result< T_OK, T_Error > Class Template Reference

Wrapper class that bifurcates the values indicated by normal and quasi-normal states. More...

#include <result.h>

Public Member Functions

 Result (const Result &result)
 
 Result (Result &&result)
 
 ~Result ()
 
Resultoperator= (const Result &result) &
 
Resultoperator= (Result &&result) &
 
 operator bool () const noexcept
 Judges whether the state is normal. More...
 
bool operator! () const noexcept
 Judges whether the state is quasi-normal. More...
 
const T_OK & get () const
 Get the value of normal state as a constant. More...
 
T_OK & get ()
 Get the value of normal state. More...
 
const T_Error & err () const
 Get the value of quasi-normal state as a constant. More...
 
T_Error & err ()
 Get the value of quasi-normal state. More...
 

Friends

template<typename T >
class ok_t
 
template<typename T >
class error_t
 

Detailed Description

template<typename T_OK, typename T_Error>
class octane::Result< T_OK, T_Error >

Wrapper class that bifurcates the values indicated by normal and quasi-normal states.

このクラスはRustに触発されてこしらえました。 実装雑なので与える型によってはコンパイル通らない可能性あり。 This class was inspired by Rust. The implementation is crude, so it may not compile depending on the type you give it.

Template Parameters
T_OKType on success.
T_ErrorType on error.
Note
C++には便利な例外機構が存在するが、例外処理は面倒な上 オーバーヘッドも地味にあるので本ライブラリではこちらを使う。 C++ has a convenient exception mechanism, but exception handling is tedious and there is an overhead, so this library uses this one.

Constructor & Destructor Documentation

◆ Result() [1/2]

template<typename T_OK , typename T_Error >
octane::Result< T_OK, T_Error >::Result ( const Result< T_OK, T_Error > &  result)
inline
Here is the call graph for this function:

◆ Result() [2/2]

template<typename T_OK , typename T_Error >
octane::Result< T_OK, T_Error >::Result ( Result< T_OK, T_Error > &&  result)
inline
Here is the call graph for this function:

◆ ~Result()

template<typename T_OK , typename T_Error >
octane::Result< T_OK, T_Error >::~Result ( )
inline
Here is the call graph for this function:

Member Function Documentation

◆ err() [1/2]

template<typename T_OK , typename T_Error >
T_Error & octane::Result< T_OK, T_Error >::err ( )
inline

Get the value of quasi-normal state.

このメソッドは事前に準正常系であることを確認してから呼び出さなければならない。 This method must be called after checking that the state is quasi-normal.

Returns
T_Error& Value of quasi-normal state.
Here is the call graph for this function:

◆ err() [2/2]

template<typename T_OK , typename T_Error >
const T_Error & octane::Result< T_OK, T_Error >::err ( ) const
inline

Get the value of quasi-normal state as a constant.

このメソッドは事前に準正常系であることを確認してから呼び出さなければならない。 This method must be called after checking that the state is quasi-normal.

Returns
const T_Error& Value of quasi-normal state.
Here is the call graph for this function:

◆ get() [1/2]

template<typename T_OK , typename T_Error >
T_OK & octane::Result< T_OK, T_Error >::get ( )
inline

Get the value of normal state.

このメソッドは必ず事前に正常系であることを確認してから呼び出さなければならない。 This method must be called after checking that the state is normal.

Returns
T_OK& Value of normal state.
Here is the call graph for this function:

◆ get() [2/2]

template<typename T_OK , typename T_Error >
const T_OK & octane::Result< T_OK, T_Error >::get ( ) const
inline

Get the value of normal state as a constant.

このメソッドは必ず事前に正常系であることを確認してから呼び出さなければならない。 This method must be called after checking that the state is normal.

Returns
const T_OK& Value of normal state.
Here is the call graph for this function:

◆ operator bool()

template<typename T_OK , typename T_Error >
octane::Result< T_OK, T_Error >::operator bool ( ) const
inlinenoexcept

Judges whether the state is normal.

Returns
true When the state is normal.
false When the state is quasi-normal.

◆ operator!()

template<typename T_OK , typename T_Error >
bool octane::Result< T_OK, T_Error >::operator! ( ) const
inlinenoexcept

Judges whether the state is quasi-normal.

Returns
true When the state is quasi-normal.
false When the state is normal.

◆ operator=() [1/2]

template<typename T_OK , typename T_Error >
Result & octane::Result< T_OK, T_Error >::operator= ( const Result< T_OK, T_Error > &  result) &
inline

◆ operator=() [2/2]

template<typename T_OK , typename T_Error >
Result & octane::Result< T_OK, T_Error >::operator= ( Result< T_OK, T_Error > &&  result) &
inline

Friends And Related Function Documentation

◆ error_t

template<typename T_OK , typename T_Error >
template<typename T >
friend class error_t
friend

◆ ok_t

template<typename T_OK , typename T_Error >
template<typename T >
friend class ok_t
friend

Member Data Documentation

◆ error

template<typename T_OK , typename T_Error >
T_Error octane::Result< T_OK, T_Error >::error

◆ ok

template<typename T_OK , typename T_Error >
T_OK octane::Result< T_OK, T_Error >::ok

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