5 #ifndef BITCOIN_UTIL_CHECK_H
6 #define BITCOIN_UTIL_CHECK_H
12 #include <string_view>
23 #define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
32 return std::forward<T>(val);
46 #define CHECK_NONFATAL(condition) \
47 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
50 #error "Cannot compile without assertions!"
54 void assertion_fail(std::string_view file,
int line, std::string_view func, std::string_view assertion);
57 template <
bool IS_ASSERT,
typename T>
60 if constexpr (IS_ASSERT
61 #ifdef ABORT_ON_FAILED_ASSUME
69 return std::forward<T>(val);
73 #define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
85 #define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
90 #define NONFATAL_UNREACHABLE() \
91 throw NonFatalCheckError( \
92 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__)
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
Helper for Assert()
T && inline_assertion_check(LIFETIMEBOUND T &&val, [[maybe_unused]] const char *file, [[maybe_unused]] int line, [[maybe_unused]] const char *func, [[maybe_unused]] const char *assertion)
Helper for Assert()/Assume()
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
#define T(expected, seed, data)