contur2
Loading...
Searching...
No Matches

Specialization of Result for void — operations that produce no value on success. More...

#include <error.h>

Public Member Functions

bool isOk () const noexcept
 Returns true if this Result represents success.
bool isError () const noexcept
 Returns true if this Result represents failure.
ErrorCode errorCode () const noexcept
 Returns the error code (Ok if successful).
const void & value () const &
 Returns a const reference to the success value.
void valueOr (void defaultValue) const &
 Returns the value if ok, or the provided default value if error.

Static Public Member Functions

static Result ok ()
 Constructs a successful void Result.
static Result error (ErrorCode code)
 Constructs a failed void Result with the given error code.

Private Member Functions

 Result (ErrorCode code)

Private Attributes

ErrorCode code_
std::variant< void, ErrorCodestorage_

Detailed Description

Specialization of Result for void — operations that produce no value on success.

Definition at line 185 of file error.h.

Constructor & Destructor Documentation

◆ Result()

contur::Result< void >::Result ( ErrorCode code)
inlineexplicitprivate

Definition at line 220 of file error.h.

Member Function Documentation

◆ error()

Result contur::Result< void >::error ( ErrorCode code)
inlinestaticnodiscard

Constructs a failed void Result with the given error code.

Definition at line 195 of file error.h.

◆ errorCode()

ErrorCode contur::Result< void >::errorCode ( ) const
inlinenodiscardnoexcept

Returns the error code (Ok if successful).

Definition at line 214 of file error.h.

◆ isError()

bool contur::Result< void >::isError ( ) const
inlinenodiscardnoexcept

Returns true if this Result represents failure.

Definition at line 208 of file error.h.

◆ isOk()

bool contur::Result< void >::isOk ( ) const
inlinenodiscardnoexcept

Returns true if this Result represents success.

Definition at line 202 of file error.h.

◆ ok()

Result contur::Result< void >::ok ( )
inlinestaticnodiscard

Constructs a successful void Result.

Definition at line 189 of file error.h.

◆ value()

const void & contur::Result< void >::value ( ) const &
inlinenodiscard

Returns a const reference to the success value.

Precondition
isOk() must be true. Undefined behavior otherwise.

Definition at line 133 of file error.h.

◆ valueOr()

void contur::Result< void >::valueOr ( void defaultValue) const &
inlinenodiscard

Returns the value if ok, or the provided default value if error.

Definition at line 164 of file error.h.

Member Data Documentation

◆ code_

ErrorCode contur::Result< void >::code_
private

Definition at line 224 of file error.h.

◆ storage_

std::variant<void, ErrorCode> contur::Result< void >::storage_
private

Definition at line 181 of file error.h.


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