Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
die.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/die.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2018 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_DIE_HEADER
12 #define TLX_DIE_HEADER
13 
14 #include <tlx/die/core.hpp>
15 
16 namespace tlx {
17 
18 /******************************************************************************/
19 // die macros
20 
21 //! Instead of std::terminate(), throw the output the message via an exception.
22 #define die(msg) \
23  tlx_die(msg)
24 
25 //! Check condition X and die miserably if false. Same as assert() except this
26 //! is also active in Release mode.
27 #define die_unless(X) \
28  tlx_die_unless(X)
29 
30 //! Check condition X and die miserably if true. Opposite of assert() except
31 //! this is also active in Release mode.
32 #define die_if(X) \
33  tlx_die_if(X)
34 
35 /******************************************************************************/
36 // die_unequal()
37 
38 //! Check that X == Y or die miserably, but output the values of X and Y for
39 //! better debugging.
40 #define die_unequal(X, Y) \
41  tlx_die_unequal(X, Y)
42 
43 //! Check that X == Y or die miserably, but output the values of X and Y for
44 //! better debugging. Only active if NDEBUG is not defined.
45 #define assert_equal(X, Y) \
46  tlx_assert_equal(X, Y)
47 
48 /******************************************************************************/
49 // die_unequal_eps()
50 
51 //! Check that ABS(X - Y) <= eps or die miserably, but output the values of X
52 //! and Y for better debugging.
53 #define die_unequal_eps(X, Y, eps) \
54  tlx_die_unequal_eps(X, Y, eps)
55 
56 //! Check that ABS(X - Y) <= 0.000001 or die miserably, but output the values of
57 //! X and Y for better debugging.
58 #define die_unequal_eps6(X, Y) \
59  tlx_die_unequal_eps6(X, Y)
60 
61 /******************************************************************************/
62 // die_unless_throws()
63 
64 //! Define to check that [code] throws and exception of given type
65 #define die_unless_throws(code, exception_type) \
66  tlx_die_unless_throws(code, exception_type)
67 
68 } // namespace tlx
69 
70 #endif // !TLX_DIE_HEADER
71 
72 /******************************************************************************/