Add more asserts

This commit is contained in:
Antonio SJ Musumeci 2026-02-26 08:44:40 -06:00 • committed by trapexit
parent 56cd831ec8
commit 099ce2d91d
3 changed files with 42 additions and 6 deletions

View file

@ -30,3 +30,27 @@ namespace assert
struct StaticAssert<true>
{};
}
#ifdef NDEBUG
#define ASSERT_NOT_NULL(ptr)
#else
#include <cassert>
#include <iostream>
#define ASSERT_NOT_NULL(ptr) \
do { \
auto *_tmp = (ptr); \
if((_tmp) == nullptr) { \
std::cerr << "ASSERT_NOT_NULL failed\n" \
<< " expression: \"" #ptr "\"\n" \
<< " file: " << __FILE__ << "\n" \
<< " line: " << __LINE__ << "\n" \
<< " function: " << __func__ << "\n"; \
assert((_tmp) != nullptr); \
} \
} while (0)
#endif