diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-10-12 22:54:15 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-11-24 09:47:29 +0100 |
commit | fac5efe730ab5b8694920547203deefc5252d294 (patch) | |
tree | 66922c7c48887aaa3c611d7315a8b3b5ea517dcc /src | |
parent | fa861569dcfff9e72686dc5f30b1faa645b4d54e (diff) |
util: Add Assume() identity function
Diffstat (limited to 'src')
-rw-r--r-- | src/util/check.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/check.h b/src/util/check.h index aca0c3d9f9..fd65cbf640 100644 --- a/src/util/check.h +++ b/src/util/check.h @@ -56,4 +56,20 @@ T get_pure_r_value(T&& val) /** Identity function. Abort if the value compares equal to zero */ #define Assert(val) ([&]() -> decltype(get_pure_r_value(val)) { auto&& check = (val); assert(#val && check); return std::forward<decltype(get_pure_r_value(val))>(check); }()) +/** + * Assume is the identity function. + * + * - Should be used to run non-fatal checks. In debug builds it behaves like + * Assert()/assert() to notify developers and testers about non-fatal errors. + * In production it doesn't warn or log anything. + * - For fatal errors, use Assert(). + * - For non-fatal errors in interactive sessions (e.g. RPC or command line + * interfaces), CHECK_NONFATAL() might be more appropriate. + */ +#ifdef ABORT_ON_FAILED_ASSUME +#define Assume(val) Assert(val) +#else +#define Assume(val) ((void)(val)) +#endif + #endif // BITCOIN_UTIL_CHECK_H |