kakoune/src/assert.hh

33 lines
555 B
C++
Raw Normal View History

2011-09-09 21:24:18 +02:00
#ifndef assert_hh_INCLUDED
#define assert_hh_INCLUDED
#include "exception.hh"
namespace Kakoune
{
struct assert_failed : logic_error
{
assert_failed(const String& message);
2012-09-04 00:17:41 +02:00
String description() const override;
2011-09-09 21:24:18 +02:00
private:
String m_message;
2011-09-09 21:24:18 +02:00
};
}
#define STRINGIFY(X) #X
#define TOSTRING(X) STRINGIFY(X)
#define COMMA ,
2011-09-09 21:24:18 +02:00
#ifdef assert
#undef assert
#endif
#define assert(condition) \
if (not (condition)) \
throw assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__))
#endif // assert_hh_INCLUDED