debug: add some constexpr/consteval asserts
This commit is contained in:
parent
4c1fb3889a
commit
867d768108
@ -46,6 +46,15 @@
|
||||
#endif
|
||||
|
||||
|
||||
constexpr void constexpr_assert (auto const &expr)
|
||||
{
|
||||
if (std::is_constant_evaluated ())
|
||||
static_cast<bool> (expr) ? void (0) : [] () { throw nullptr; } ();
|
||||
else
|
||||
assert (expr);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define SCOPED_SANITY(A) \
|
||||
::cruft::debug::scoped_sanity PASTE(__scoped_sanity_checker,__LINE__) ((A)); \
|
||||
|
@ -58,6 +58,15 @@ panic [[noreturn]] (const std::string &msg)
|
||||
}
|
||||
|
||||
|
||||
template <typename TagT = void>
|
||||
constexpr void consteval_panic (void) noexcept {
|
||||
if constexpr (std::is_same_v<TagT, void>) {
|
||||
throw nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// not_implemented/unreachable/panic must be callable from constexpr contexts.
|
||||
// but they rely on functions that aren't constexpr to perform the controlled
|
||||
|
Loading…
Reference in New Issue
Block a user