diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-09 19:24:18 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-09 19:24:18 +0000 |
| commit | 030c5caf0a92c03ec2afca677483044de3bbef56 (patch) | |
| tree | 055c2ac245445c338ed94321bb56d4154d02dbd8 /src/assert.hh | |
| parent | 3caf96211085254ab3c42a59ce2c80a4ade3d2d8 (diff) | |
assert: custom implementation
Diffstat (limited to 'src/assert.hh')
| -rw-r--r-- | src/assert.hh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/assert.hh b/src/assert.hh new file mode 100644 index 00000000..c1bfd66b --- /dev/null +++ b/src/assert.hh @@ -0,0 +1,31 @@ +#ifndef assert_hh_INCLUDED +#define assert_hh_INCLUDED + +#include "exception.hh" + +namespace Kakoune +{ + +struct assert_failed : logic_error +{ + assert_failed(const std::string& message); + std::string description() const; + +private: + std::string m_message; +}; + +} + +#define STRINGIFY(X) #X +#define TOSTRING(X) STRINGIFY(X) + +#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 |
