Monero
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions
expect.h File Reference
#include <cassert>
#include <system_error>
#include <type_traits>
#include <utility>
#include "common/error.h"
Include dependency graph for expect.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  detail::expect
 
class  expect< T >
 
class  expect< void >
 

Namespaces

namespace  detail
 declaration and default definition for the functions used the API
 

Macros

#define MONERO_PRECOND(...)
 If precondition fails, return ::error::kInvalidArgument in current scope.
 
#define MONERO_CHECK(...)
 Check expect<void> and return errors in current scope.
 
#define MONERO_UNWRAP(...)    ::detail::expect::unwrap( __VA_ARGS__ , nullptr, __FILE__ , __LINE__ )
 
#define MONERO_THROW(code, msg)    ::detail::expect::throw_( code , msg , __FILE__ , __LINE__ )
 

Typedefs

template<bool C>
using detail::enable_if = typename std::enable_if<C>::type
 

Functions

expect< void > success () noexcept
 
template<typename T , typename U >
bool operator== (expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
 
template<typename T , typename U >
bool operator== (expect< T > const &lhs, U const &rhs) noexcept(noexcept(lhs.equal(rhs)))
 
template<typename T , typename U >
bool operator== (T const &lhs, expect< U > const &rhs) noexcept(noexcept(rhs.equal(lhs)))
 
template<typename T , typename U >
bool operator!= (expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
 
template<typename T , typename U >
bool operator!= (expect< T > const &lhs, U const &rhs) noexcept(noexcept(lhs.equal(rhs)))
 
template<typename T , typename U >
bool operator!= (T const &lhs, expect< U > const &rhs) noexcept(noexcept(rhs.equal(lhs)))
 

Macro Definition Documentation

◆ MONERO_CHECK

#define MONERO_CHECK ( ...)
Value:
do \
{ \
const ::expect<void> result = __VA_ARGS__ ; \
if (!result) \
return result.error(); \
} while (0)
tools::wallet2::message_signature_result_t result
Definition signature.cpp:62

Check expect<void> and return errors in current scope.

◆ MONERO_PRECOND

#define MONERO_PRECOND ( ...)
Value:
do \
{ \
if (!( __VA_ARGS__ )) \
} while (0)
@ kInvalidArgument
A function argument is invalid.

If precondition fails, return ::error::kInvalidArgument in current scope.

◆ MONERO_THROW

#define MONERO_THROW ( code,
msg )    ::detail::expect::throw_( code , msg , __FILE__ , __LINE__ )

◆ MONERO_UNWRAP

#define MONERO_UNWRAP ( ...)     ::detail::expect::unwrap( __VA_ARGS__ , nullptr, __FILE__ , __LINE__ )

Get T from expect<T> by std::move as-if by function call. expect<void> returns nothing.

Exceptions
std::system_errorwith expect<T>::error(), filename and line number when expect<T>::has_error() == true.

Function Documentation

◆ operator!=() [1/3]

template<typename T , typename U >
bool operator!= ( expect< T > const & lhs,
expect< U > const & rhs )
inlinenoexcept

◆ operator!=() [2/3]

template<typename T , typename U >
bool operator!= ( expect< T > const & lhs,
U const & rhs )
inlinenoexcept

◆ operator!=() [3/3]

template<typename T , typename U >
bool operator!= ( T const & lhs,
expect< U > const & rhs )
inlinenoexcept

◆ operator==() [1/3]

template<typename T , typename U >
bool operator== ( expect< T > const & lhs,
expect< U > const & rhs )
inlinenoexcept

◆ operator==() [2/3]

template<typename T , typename U >
bool operator== ( expect< T > const & lhs,
U const & rhs )
inlinenoexcept

◆ operator==() [3/3]

template<typename T , typename U >
bool operator== ( T const & lhs,
expect< U > const & rhs )
inlinenoexcept

◆ success()

expect< void > success ( )
inlinenoexcept
Returns
An expect<void> object with !has_error().