Electroneum
expect< void > Class Template Reference

#include <expect.h>

Public Types

using value_type = void
 
using error_type = std::error_code
 

Public Member Functions

 expect () noexcept
 Create a successful object. More...
 
 expect (std::error_code const &code) noexcept
 
 expect (expect const &)=default
 
 ~expect ()=default
 
expectoperator= (expect const &)=default
 
 operator bool () const noexcept
 
bool has_error () const noexcept
 
std::error_code error () const noexcept
 
bool equal (expect const &rhs) const noexcept
 
bool equal (std::error_code const &rhs) const noexcept
 
bool matches (std::error_condition const &rhs) const noexcept
 

Detailed Description

template<>
class expect< void >

Definition at line 344 of file expect.h.

Member Typedef Documentation

◆ error_type

using expect< void >::error_type = std::error_code

Definition at line 350 of file expect.h.

◆ value_type

using expect< void >::value_type = void

Definition at line 349 of file expect.h.

Constructor & Destructor Documentation

◆ expect() [1/3]

expect< void >::expect ( )
inlinenoexcept

Create a successful object.

Definition at line 353 of file expect.h.

354  : code_()
355  {}

◆ expect() [2/3]

expect< void >::expect ( std::error_code const &  code)
inlinenoexcept

Definition at line 357 of file expect.h.

358  : code_(code)
359  {
360  if (!has_error())
361  code_ = ::common_error::kInvalidErrorCode;
362  }
bool has_error() const noexcept
Definition: expect.h:372
Here is the call graph for this function:

◆ expect() [3/3]

expect< void >::expect ( expect< void > const &  )
default

◆ ~expect()

expect< void >::~expect ( )
default

Member Function Documentation

◆ equal() [1/2]

bool expect< void >::equal ( expect< void > const &  rhs) const
inlinenoexcept
Returns
error() == rhs.error().

Definition at line 378 of file expect.h.

379  {
380  return error() == rhs.error();
381  }
std::error_code error() const noexcept
Definition: expect.h:375
Here is the call graph for this function:
Here is the caller graph for this function:

◆ equal() [2/2]

bool expect< void >::equal ( std::error_code const &  rhs) const
inlinenoexcept
Returns
has_error() && error() == rhs.

Definition at line 384 of file expect.h.

385  {
386  return has_error() && error() == rhs;
387  }
bool has_error() const noexcept
Definition: expect.h:372
std::error_code error() const noexcept
Definition: expect.h:375
Here is the call graph for this function:

◆ error()

std::error_code expect< void >::error ( ) const
inlinenoexcept
Returns
Error - alway

Definition at line 375 of file expect.h.

375 { return code_; }

◆ has_error()

bool expect< void >::has_error ( ) const
inlinenoexcept
Returns
True if this is storing an error instead of a value.

Definition at line 372 of file expect.h.

372 { return bool(code_); }
int bool
Definition: stdbool.h:36

◆ matches()

bool expect< void >::matches ( std::error_condition const &  rhs) const
inlinenoexcept
Returns
False if has_value(), otherwise error() == rhs.

Definition at line 390 of file expect.h.

391  {
392  return has_error() && error() == rhs;
393  }
bool has_error() const noexcept
Definition: expect.h:372
std::error_code error() const noexcept
Definition: expect.h:375
Here is the call graph for this function:

◆ operator bool()

expect< void >::operator bool ( ) const
inlineexplicitnoexcept
Returns
True if this is storing a value instead of an error.

Definition at line 369 of file expect.h.

369 { return !has_error(); }
bool has_error() const noexcept
Definition: expect.h:372
Here is the call graph for this function:

◆ operator=()

expect& expect< void >::operator= ( expect< void > const &  )
default

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