Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
die_with_message.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/common/die_with_message.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2018 Manuel Penschuck <[email protected]>
7  *
8  * Distributed under the Boost Software License, Version 1.0.
9  * (See accompanying file LICENSE_1_0.txt or copy at
10  * http://www.boost.org/LICENSE_1_0.txt)
11  **************************************************************************/
12 
13 #ifndef FOXXLL_COMMON_DIE_WITH_MESSAGE_HEADER
14 #define FOXXLL_COMMON_DIE_WITH_MESSAGE_HEADER
15 
16 #include <tlx/die/core.hpp>
17 
18 // These macros are a compat layer until we have stream support in die_if/die_unless
19 
20 //! Check condition X and die miserably if false. Same as die_if()
21 //! except user additionally pass message
22 #define die_with_message_if(X, msg) \
23  do { \
24  if ((X)) { \
25  tlx_die_with_sstream( \
26  "DIE: Assertion \"" #X "\" succeeded!\n " << msg << "\n" \
27  ); \
28  } \
29  } while (false)
30 
31 //! Check condition X and die miserably if false. Same as die_unless()
32 //! except user additionally pass message
33 #define die_with_message_unless(X, msg) \
34  do { \
35  if (!(X)) { \
36  tlx_die_with_sstream( \
37  "DIE: Assertion \"" #X "\" failed!\n " << msg << "\n" \
38  ); \
39  } \
40  } while (false)
41 
42 #endif // !FOXXLL_COMMON_DIE_WITH_MESSAGE_HEADER
43 
44 /**************************************************************************/