]> git.lyx.org Git - lyx.git/blobdiff - src/support/LAssert.h
Small things in my tree.
[lyx.git] / src / support / LAssert.h
index dbe9de24fed04e9e576d8fd0d398750507af8cff..f44f9ceaa201956f4f704e12669f28e2005b98ed 100644 (file)
@@ -1,43 +1,33 @@
 // -*- C++ -*-
-#ifndef _LASSERT_H_
-#define _LASSERT_H_
+#ifndef LASSERT_H
+#define LASSERT_H
+
+#include "support/lyxlib.h"
 
 //namespace LyX {
 
-#define HAVE_TEMPLATE
-#ifdef HAVE_TEMPLATE
-//template<class X, class A> inline void Assert(A assertion)
-template<class A> inline void Assert(A assertion)
-{
-       //if (!assertion) throw X();
-       if (!assertion) {
-               abort();
-       }
-}
+#ifdef ENABLE_ASSERTIONS
+
+extern void emergencySave();
 
-#ifdef HAVE_PARTIAL_SPECIALIZATION
-// Not too sure if this is the correct way to specialize
-template<class A> inline void Assert(A * ptr)
+template<class A>
+inline
+void Assert(A assertion)
 {
-       if (!ptr) {
-               abort();
+       if (!assertion) {
+               ::emergencySave();
+               lyx::abort();
        }
 }
-#endif
-
-//template<class A, class E> inline void Assert(A assertion, E except)
-//{
-//     if (!assertion) except;
-//}
 
 #else
 
-inline void lyx_assert(...)
-{
-       // nothing
-}
+template<class A>
+inline
+void Assert(A /*assertion*/) {}
 
-#endif
-#endif
+#endif /* ENABLE_ASSERTIONS */
 
 //} // end of namespace LyX
+#endif /* LASSERT_H */
+