#ifndef ASSERT_HPP #define ASSERT_HPP #include #ifdef NDEBUG #define ASSERT(condition) ((void)0) #else #define ASSERT(condition) (safe_assert((condition), #condition, \ __FILE__, __LINE__, __func__)) #endif inline void safe_assert(bool condition, const char* condition_text, const char* filename, int line, const char* function) noexcept { if (!condition) { try { std::cerr << "Assertion failed: " << condition_text << ", file " << filename << ", line " << line << ", function " << function << std::endl; } catch (...) { /* we want to keep the noexcept promise */ } std::abort(); } } #endif