Contains the Result class which is used to return the result of a function.
More...
#include "libmicroemu/status_code.h"
#include "libmicroemu/types.h"
#include <cstdlib>
#include <string_view>
#include <type_traits>
Go to the source code of this file.
|
| #define | TRY_ASSIGN(NAME, OUT_TYPE, CALL) |
| | Try to assign a value to a variable and return an error if the assignment fails.
|
| |
| #define | TRY(OUT_TYPE, CALL) |
| | Try to call a function and return an error if the call fails.
|
| |
|
|
template<typename T> |
| static constexpr Result< T > | libmicroemu::internal::Ok (const T &content) noexcept |
| |
|
static constexpr Result< void > | libmicroemu::internal::Ok () noexcept |
| |
|
template<typename T> |
| static constexpr Result< T > | libmicroemu::internal::Err (const StatusCode &sc) noexcept |
| |
|
static constexpr Result< void > | libmicroemu::internal::Err (const StatusCode &sc) noexcept |
| |
|
template<typename TIn, typename TRet> |
| static constexpr std::enable_if_t<!std::is_same_v< TRet, void >, Result< TRet > > | libmicroemu::internal::Err (const Result< TIn > &res) noexcept |
| |
|
template<typename TIn, typename TRet> |
| static constexpr std::enable_if_t< std::is_same_v< TRet, void >, Result< TRet > > | libmicroemu::internal::Err (const Result< TIn > &res) noexcept |
| |
Contains the Result class which is used to return the result of a function.
◆ TRY
| #define TRY |
( |
| OUT_TYPE, |
|
|
| CALL ) |
Value: { \
auto r_tmp = CALL; \
if (r_tmp.IsErr()) { \
using t_ret_decl = decltype(CALL); \
using t_ret = typename t_ret_decl::Content; \
return Err<t_ret, OUT_TYPE>(r_tmp); \
}; \
}
Try to call a function and return an error if the call fails.
- Parameters
-
| OUT_TYPE | The type of the output |
| CALL | The call to make |
◆ TRY_ASSIGN
| #define TRY_ASSIGN |
( |
| NAME, |
|
|
| OUT_TYPE, |
|
|
| CALL ) |
Value: auto r_##NAME = CALL; \
if (r_##NAME.IsErr()) { \
using t_ret_decl = decltype(CALL); \
using t_ret = typename t_ret_decl::Content; \
return Err<t_ret, OUT_TYPE>(r_##NAME); \
}; \
const auto &NAME = r_##NAME.content;
Try to assign a value to a variable and return an error if the assignment fails.
- Parameters
-
| NAME | The name of the variable to assign |
| OUT_TYPE | The type of the output |
| CALL | The call to make to get the value |