]> git.lyx.org Git - lyx.git/blob - src/support/LAssert.h
make doc++ able to generate the source documentation for lyx
[lyx.git] / src / support / LAssert.h
1 // -*- C++ -*-
2 #ifndef LASSERT_H
3 #define LASSERT_H
4
5 #include "support/lyxlib.h"
6
7 //namespace LyX {
8
9 #ifdef ENABLE_ASSERTIONS
10
11 extern void emergencySave();
12
13 /** Live assertion.
14     This is a debug tool to ensure that the assertion holds. If it don't hole
15     we run #emergencySave()# and then #lyx::abort".
16     @param assertion this should evaluate to true unless you want an abort.
17 */
18 template<class A>
19 inline
20 void Assert(A assertion)
21 {
22         if (!assertion) {
23                 ::emergencySave();
24                 lyx::abort();
25         }
26 }
27
28 #else
29
30 /** Dummy assertion.
31     When compiling without assertions we use this no-op function.
32 */
33 template<class A>
34 inline
35 void Assert(A /*assertion*/) {}
36
37 #endif /* ENABLE_ASSERTIONS */
38
39 //} // end of namespace LyX
40 #endif /* LASSERT_H */