]> git.lyx.org Git - lyx.git/blob - src/support/LAssert.h
Add -enable-assertions to configure, cleanup assertions, fix crash in LyXFont::ascent...
[lyx.git] / src / support / LAssert.h
1 // -*- C++ -*-
2 #ifndef LASSERT_H
3 #define LASSERT_H
4
5 //namespace LyX {
6
7 #ifdef ENABLE_ASSERTIONS
8
9 //template<class X, class A> inline void Assert(A assertion)
10 template<class A> inline void Assert(A assertion)
11 {
12         //if (!assertion) throw X();
13         if (!assertion) {
14                 abort();
15         }
16 }
17
18 #ifdef HAVE_PARTIAL_SPECIALIZATION
19 // Not too sure if this is the correct way to specialize
20 template<class A> inline void Assert(A * ptr)
21 {
22         if (!ptr) {
23                 abort();
24         }
25 }
26 #endif /* HAVE_PARTIAL_SPECIALIZATION  */ 
27
28 //template<class A, class E> inline void Assert(A assertion, E except)
29 //{
30 //      if (!assertion) except;
31 //}
32
33 #else
34
35 template<class A> inline void Assert(A /*assertion*/) {;}
36
37 #endif /* ENABLE_ASSERTIONS */
38
39
40 //} // end of namespace LyX
41
42
43 #endif /* LASSERT_H */
44