light/modules/debug/include/debug/assertions.hpp

25 lines
640 B
C++
Raw Normal View History

#pragma once
#include <logger/logger.hpp>
2025-07-11 00:05:48 +03:30
namespace lt {
struct FailedAssertion: std::exception
{
FailedAssertion(const char *file, int line)
{
log_crt("Assertion failed in: {} (line {})", file, line);
}
};
2025-07-11 00:24:44 +03:30
#define lt_assert(x, ...) \
{ \
if (!(x)) \
{ \
log_crt(__VA_ARGS__); \
2025-07-11 00:05:48 +03:30
throw ::lt::FailedAssertion(__FILE__, __LINE__); \
2025-07-11 00:24:44 +03:30
} \
}
2025-07-11 00:05:48 +03:30
} // namespace lt