#ifndef LASSERT_H
#define LASSERT_H
-//namespace LyX {
+#include "support/lyxlib.h"
+
+extern void emergencyCleanup();
+
+namespace lyx {
#ifdef ENABLE_ASSERTIONS
-//template<class X, class A> inline void Assert(A assertion)
-template<class A> inline void Assert(A assertion)
+/** Live assertion.
+ This is a debug tool to ensure that the assertion holds. If it don't hole
+ we run #emergencyCleanup()# and then #lyx::abort".
+ @param assertion this should evaluate to true unless you want an abort.
+*/
+template<class A>
+inline
+void Assert(A assertion)
{
- //if (!assertion) throw X();
if (!assertion) {
- abort();
- }
-}
-
-#ifdef HAVE_PARTIAL_SPECIALIZATION
-// Not too sure if this is the correct way to specialize
-template<class A> inline void Assert(A * ptr)
-{
- if (!ptr) {
- abort();
+ ::emergencyCleanup();
+ lyx::abort();
}
}
-#endif /* HAVE_PARTIAL_SPECIALIZATION */
-
-//template<class A, class E> inline void Assert(A assertion, E except)
-//{
-// if (!assertion) except;
-//}
#else
-template<class A> inline void Assert(A /*assertion*/) {;}
+/** Dummy assertion.
+ When compiling without assertions we use this no-op function.
+*/
+template<class A>
+inline
+void Assert(A /*assertion*/) {}
#endif /* ENABLE_ASSERTIONS */
-
-//} // end of namespace LyX
-
+} // end of namespace LyX
#endif /* LASSERT_H */
-