16 #define OPENGM_CHECK_OP(a,op,b,message) \
17 if(! static_cast<bool>( a op b ) ) { \
18 std::stringstream s; \
19 s << "OpenGM Error: "<< message <<"\n";\
20 s << "OpenGM check : " << #a <<#op <<#b<< " failed:\n"; \
21 s << #a " = "<<a<<"\n"; \
22 s << #b " = "<<b<<"\n"; \
23 s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
24 throw std::runtime_error(s.str()); \
27 #define OPENGM_CHECK(expression,message) if(!(expression)) { \
28 std::stringstream s; \
30 s << "OpenGM assertion " << #expression \
31 << " failed in file " << __FILE__ \
32 << ", line " << __LINE__ << std::endl; \
33 throw std::runtime_error(s.str()); \
40 #define OPENGM_ASSERT_OP(a,op,b) { }
42 #define OPENGM_ASSERT_OP(a,op,b) \
43 if(! static_cast<bool>( a op b ) ) { \
44 std::stringstream s; \
45 s << "OpenGM assertion : " << #a <<#op <<#b<< " failed:\n"; \
46 s << #a " = "<<a<<"\n"; \
47 s << #b " = "<<b<<"\n"; \
48 s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
49 throw std::runtime_error(s.str()); \
53 #define OPENGM_ASSERT_OP(a,op,b) \
54 if(! static_cast<bool>( a op b ) ) { \
55 std::stringstream s; \
56 s << "OpenGM assertion : " << #a <<#op <<#b<< " failed:\n"; \
57 s << #a " = "<<a<<"\n"; \
58 s << #b " = "<<b<<"\n"; \
59 s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
60 throw std::runtime_error(s.str()); \
66 #define OPENGM_ASSERT(expression) {}
68 #define OPENGM_ASSERT(expression) if(!(expression)) { \
69 std::stringstream s; \
70 s << "OpenGM assertion " << #expression \
71 << " failed in file " << __FILE__ \
72 << ", line " << __LINE__ << std::endl; \
73 throw std::runtime_error(s.str()); \
77 #define OPENGM_ASSERT(expression) if(!(expression)) { \
78 std::stringstream s; \
79 s << "OpenGM assertion " << #expression \
80 << " failed in file " << __FILE__ \
81 << ", line " << __LINE__ << std::endl; \
82 throw std::runtime_error(s.str()); \
87 #define OPENGM_META_ASSERT(assertion, msg) { \
88 meta::Assert< meta::Compare< meta::Bool<(assertion)> , meta::Bool<true> >::value > \
89 OPENGM_COMPILE_TIME_ASSERTION_FAILED_____REASON_____##msg; \
90 (void) OPENGM_COMPILE_TIME_ASSERTION_FAILED_____REASON_____##msg; \
101 :
public std::runtime_error
103 typedef std::runtime_error
base;
106 : base(
std::string(
"OpenGM error: ") + message) {}
111 inline T
abs(
const T& x) {
112 return x > 0 ? x : -x;
117 return x >= y ? x : y;
122 return x <= y ? x : y;
127 #endif // #ifndef OPENGM_HXX
opengm::UIntType SerializationIndexType
T opengmMax(const T &x, const T &y)
BiggestUIntType UIntType
default uint (biggest / longest uint)
T opengmMin(const T &x, const T &y)
RuntimeError(const std::string &message)