]> www.ginac.de Git - ginac.git/blob - ginac/polynomial/debug.hpp
Merge branch 'master' of git://ffmssmsc.jinr.ru:443/varg/ginac
[ginac.git] / ginac / polynomial / debug.hpp
1 #ifndef GINAC_MOD_GCD_DEBUG_HPP
2 #define GINAC_MOD_GCD_DEBUG_HPP
3 #include <iostream>
4 #include <string>
5 #include <stdexcept>
6 #include <sstream>
7
8 #define DEBUG_PREFIX __func__ << ':' << __LINE__ << ": "
9 #define EXCEPTION_PREFIX std::string(__func__) + std::string(": ") +
10
11 #define Dout2(stream, msg) \
12 do {                                                                    \
13         stream << DEBUG_PREFIX << msg << std::endl << std::flush;       \
14 } while (0)
15 #define Dout(msg) Dout2(std::cout, msg)
16
17 #define bug3_on(condition, the_exception, msg)                          \
18 do {                                                                    \
19         if (unlikely(condition)) {                                      \
20                 std::ostringstream err_stream;                          \
21                 Dout2(err_stream, "BUG: " << msg);                      \
22                 throw the_exception(err_stream.str());                  \
23         }                                                               \
24 } while (0)
25
26 #define bug_on(condition, msg) bug3_on(condition, std::logic_error, msg)
27
28 #endif // GINAC_MOD_GCD_DEBUG_HPP
29