-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbg.hpp
30 lines (25 loc) · 1.06 KB
/
dbg.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef DBG_H_
#define DBG_H_
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define E(e) (TOSTRING(e) "<") << (e) << '>'
// Own assert with message
#ifdef NDEBUG
#define assert2(condition, message) do { } while(false)
#else
#include <exception>
#include <stdexcept>
#include <iostream>
#define assert2(condition, message) \
do { \
if(!(condition)) { \
std::cerr << "Assertion failed: (" << #condition << "), " \
<< __FUNCTION__ \
<< '@' << __FILE__ \
<< ':' << __LINE__ << '.' \
<< '\n' << message << std::endl; \
throw std::logic_error("Assert2"); \
} \
} while(false)
#endif
#endif // DBG_H_