Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::result_void Class Reference

Wrapper for void result. More...

#include <error_handling.h>

Collaboration diagram for kcenon::thread::result_void:
Collaboration graph

Public Member Functions

 result_void ()=default
 Constructs a successful result.
 
 result_void (const error &err)
 Constructs a result with an error.
 
bool has_error () const noexcept
 Checks if the result contains an error.
 
bool has_value () const noexcept
 Checks if the result is successful (has a value)
 
bool is_ok () const noexcept
 Checks if the result is successful.
 
bool is_error () const noexcept
 Checks if the result contains an error.
 
const errorget_error () const
 Gets the error.
 
 operator bool () const noexcept
 Converts to bool for condition checking.
 

Private Attributes

bool has_error_ = false
 
error error_ {error_code::success, ""}
 

Detailed Description

Wrapper for void result.

This class represents a result that doesn't return a value (void), but can indicate success or failure.

Definition at line 187 of file error_handling.h.

Constructor & Destructor Documentation

◆ result_void() [1/2]

kcenon::thread::result_void::result_void ( )
default

Constructs a successful result.

◆ result_void() [2/2]

kcenon::thread::result_void::result_void ( const error & err)
inline

Constructs a result with an error.

Parameters
errThe error

Definition at line 198 of file error_handling.h.

Member Function Documentation

◆ get_error()

const error & kcenon::thread::result_void::get_error ( ) const
inlinenodiscard

Gets the error.

Returns
A reference to the contained error

Definition at line 231 of file error_handling.h.

231{ return error_; }

References error_.

◆ has_error()

bool kcenon::thread::result_void::has_error ( ) const
inlinenodiscardnoexcept

Checks if the result contains an error.

Returns
true if the result contains an error, false otherwise

Definition at line 204 of file error_handling.h.

204{ return has_error_; }

References has_error_.

◆ has_value()

bool kcenon::thread::result_void::has_value ( ) const
inlinenodiscardnoexcept

Checks if the result is successful (has a value)

Returns
true if successful, false if it contains an error
Note
Added for API compatibility with common::Result and result<T>

Definition at line 211 of file error_handling.h.

211{ return !has_error_; }

References has_error_.

◆ is_error()

bool kcenon::thread::result_void::is_error ( ) const
inlinenodiscardnoexcept

Checks if the result contains an error.

Returns
true if the result contains an error, false otherwise
Note
Added for API compatibility with common::Result

Definition at line 225 of file error_handling.h.

225{ return has_error_; }

References has_error_.

◆ is_ok()

bool kcenon::thread::result_void::is_ok ( ) const
inlinenodiscardnoexcept

Checks if the result is successful.

Returns
true if successful, false if it contains an error
Note
Added for API compatibility with common::Result

Definition at line 218 of file error_handling.h.

218{ return !has_error_; }

References has_error_.

◆ operator bool()

kcenon::thread::result_void::operator bool ( ) const
inlineexplicitnoexcept

Converts to bool for condition checking.

Returns
true if successful (no error), false otherwise

Definition at line 237 of file error_handling.h.

237{ return !has_error_; }

References has_error_.

Member Data Documentation

◆ error_

error kcenon::thread::result_void::error_ {error_code::success, ""}
private

Definition at line 241 of file error_handling.h.

Referenced by get_error().

◆ has_error_

bool kcenon::thread::result_void::has_error_ = false
private

Definition at line 240 of file error_handling.h.

Referenced by has_error(), has_value(), is_error(), is_ok(), and operator bool().


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