Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
common::Result< T > Class Template Reference

#include <common_result.h>

Collaboration diagram for common::Result< T >:
Collaboration graph

Public Member Functions

 Result (T value)
 
 Result (error_info error)
 
bool is_ok () const
 
bool is_error () const
 
T & value ()
 
const T & value () const
 
error_infoerror ()
 
const error_infoerror () const
 

Private Attributes

std::variant< T, error_infodata_
 

Detailed Description

template<typename T>
class common::Result< T >
Examples
/home/runner/work/database_system/database_system/database/integrated/core/database_coordinator.h.

Definition at line 56 of file common_result.h.

Constructor & Destructor Documentation

◆ Result() [1/2]

template<typename T >
common::Result< T >::Result ( T value)
inline

Definition at line 58 of file common_result.h.

58: data_(std::move(value)) {}
std::variant< T, error_info > data_

◆ Result() [2/2]

template<typename T >
common::Result< T >::Result ( error_info error)
inline

Definition at line 59 of file common_result.h.

59: data_(std::move(error)) {}
error_info & error()

Member Function Documentation

◆ error() [1/2]

template<typename T >
error_info & common::Result< T >::error ( )
inline

Definition at line 67 of file common_result.h.

67{ return std::get<error_info>(data_); }

References common::Result< T >::data_.

◆ error() [2/2]

template<typename T >
const error_info & common::Result< T >::error ( ) const
inline

Definition at line 68 of file common_result.h.

68{ return std::get<error_info>(data_); }

References common::Result< T >::data_.

◆ is_error()

template<typename T >
bool common::Result< T >::is_error ( ) const
inline

Definition at line 62 of file common_result.h.

62{ return !is_ok(); }
bool is_ok() const

References common::Result< T >::is_ok().

Here is the call graph for this function:

◆ is_ok()

template<typename T >
bool common::Result< T >::is_ok ( ) const
inline

Definition at line 61 of file common_result.h.

61{ return std::holds_alternative<T>(data_); }

References common::Result< T >::data_.

Referenced by common::Result< T >::is_error().

Here is the caller graph for this function:

◆ value() [1/2]

template<typename T >
T & common::Result< T >::value ( )
inline

Definition at line 64 of file common_result.h.

64{ return std::get<T>(data_); }

References common::Result< T >::data_.

◆ value() [2/2]

template<typename T >
const T & common::Result< T >::value ( ) const
inline

Definition at line 65 of file common_result.h.

65{ return std::get<T>(data_); }

References common::Result< T >::data_.

Member Data Documentation

◆ data_


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