Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::common::Result< T > Class Template Reference

#include <error_codes.h>

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

Public Member Functions

 Result ()=default
 
 Result (T value)
 
 Result (error_info info)
 
bool has_value () const
 
bool has_error () const
 
T & value ()
 
const T & value () const
 
error_infoerror ()
 
const error_infoerror () const
 

Private Attributes

std::optional< T > value_
 
std::optional< error_infoerror_
 

Detailed Description

Constructor & Destructor Documentation

◆ Result() [1/3]

◆ Result() [2/3]

template<typename T >
kcenon::common::Result< T >::Result ( T value)
inlineexplicit

Definition at line 74 of file error_codes.h.

75 : value_(std::move(value)) {}
std::optional< T > value_

◆ Result() [3/3]

template<typename T >
kcenon::common::Result< T >::Result ( error_info info)
inlineexplicit

Definition at line 77 of file error_codes.h.

78 : error_(std::move(info)) {}
std::optional< error_info > error_

Member Function Documentation

◆ error() [1/2]

template<typename T >
error_info & kcenon::common::Result< T >::error ( )
inline
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/core/error_codes.h.

Definition at line 97 of file error_codes.h.

97 {
98 if (!error_) {
99 throw std::logic_error("Result does not contain an error");
100 }
101 return *error_;
102 }

References kcenon::common::Result< T >::error_.

Referenced by kcenon::common::get_error(), and kcenon::common::get_error().

Here is the caller graph for this function:

◆ error() [2/2]

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

Definition at line 104 of file error_codes.h.

104 {
105 if (!error_) {
106 throw std::logic_error("Result does not contain an error");
107 }
108 return *error_;
109 }

References kcenon::common::Result< T >::error_.

◆ has_error()

template<typename T >
bool kcenon::common::Result< T >::has_error ( ) const
inline
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/core/error_codes.h.

Definition at line 81 of file error_codes.h.

81{ return error_.has_value(); }

References kcenon::common::Result< T >::error_.

Referenced by kcenon::common::is_error().

Here is the caller graph for this function:

◆ has_value()

template<typename T >
bool kcenon::common::Result< T >::has_value ( ) const
inline
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/core/error_codes.h.

Definition at line 80 of file error_codes.h.

80{ return value_.has_value(); }

References kcenon::common::Result< T >::value_.

Referenced by kcenon::common::is_ok().

Here is the caller graph for this function:

◆ value() [1/2]

template<typename T >
T & kcenon::common::Result< T >::value ( )
inline
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/core/error_codes.h.

Definition at line 83 of file error_codes.h.

83 {
84 if (!value_) {
85 throw std::logic_error("Result does not contain a value");
86 }
87 return *value_;
88 }

References kcenon::common::Result< T >::value_.

Referenced by kcenon::common::get_value(), and kcenon::common::get_value().

Here is the caller graph for this function:

◆ value() [2/2]

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

Definition at line 90 of file error_codes.h.

90 {
91 if (!value_) {
92 throw std::logic_error("Result does not contain a value");
93 }
94 return *value_;
95 }

References kcenon::common::Result< T >::value_.

Member Data Documentation

◆ error_

◆ value_


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