5#ifndef BITCOIN_UTIL_CHECK_H
6#define BITCOIN_UTIL_CHECK_H
16std::string
StrFormatInternalBug(std::string_view msg, std::string_view file,
int line, std::string_view func);
21 NonFatalCheckError(std::string_view msg, std::string_view file,
int line, std::string_view func);
31 return std::forward<T>(val);
35#error "Cannot compile without assertions!"
39void assertion_fail(std::string_view file,
int line, std::string_view func, std::string_view assertion);
42template <
bool IS_ASSERT,
typename T>
45 if constexpr (IS_ASSERT
46#ifdef ABORT_ON_FAILED_ASSUME
54 return std::forward<T>(val);
60#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
73#define CHECK_NONFATAL(condition) \
74 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
77#define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
89#define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
94#define NONFATAL_UNREACHABLE() \
95 throw NonFatalCheckError( \
96 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__)
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
T && inline_assertion_check(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for Assert()/Assume()
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
Helper for Assert()
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
#define T(expected, seed, data)