tlx
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
die.hpp File Reference
#include <cstring>
#include <sstream>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Classes

class  DieException
 Exception thrown by die_with_message() if. More...
 

Namespaces

 tlx
 

Macros

#define die_with_sstream(msg)
 Instead of std::terminate(), throw the output the message via an exception. More...
 
#define die(msg)
 Instead of std::terminate(), throw the output the message via an exception. More...
 
#define die_unless(X)
 Check condition X and die miserably if false. More...
 
#define die_if(X)
 Check condition X and die miserably if true. More...
 
#define die_unequal(X, Y)
 Check that X == Y or die miserably, but output the values of X and Y for better debugging. More...
 
#define assert_equal(X, Y)
 Check that X == Y or die miserably, but output the values of X and Y for better debugging. More...
 
#define die_unequal_eps(X, Y, eps)
 Check that ABS(X - Y) <= eps or die miserably, but output the values of X and Y for better debugging. More...
 
#define die_unequal_eps6(X, Y)
 Check that ABS(X - Y) <= 0.000001 or die miserably, but output the values of X and Y for better debugging. More...
 
#define die_unless_throws(code, exception_type)
 Define to check that [code] throws and exception of given type. More...
 

Functions

void die_with_message (const std::string &msg)
 die with message - either throw an exception or die via std::terminate() More...
 
void die_with_message (const char *msg, const char *file, size_t line)
 die with message - either throw an exception or die via std::terminate() More...
 
void die_with_message (const std::string &msg, const char *file, size_t line)
 die with message - either throw an exception or die via std::terminate() More...
 
bool set_die_with_exception (bool b)
 Switch between dying via std::terminate() and throwing an exception. More...
 
template<typename TypeA , typename TypeB >
bool die_equal_compare (TypeA a, TypeB b)
 helper method to compare two values in die_unequal() More...
 
template<>
bool die_equal_compare (const char *a, const char *b)
 
template<>
bool die_equal_compare (float a, float b)
 
template<>
bool die_equal_compare (double a, double b)
 
template<typename Type >
Type die_unequal_eps_abs (const Type &t)
 simple replacement for std::abs More...
 
template<typename TypeA , typename TypeB >
bool die_equal_eps_compare (TypeA x, TypeB y, double eps)
 helper method to compare two values in die_unequal_eps() More...
 

Macro Definition Documentation

#define assert_equal (   X,
 
)

Check that X == Y or die miserably, but output the values of X and Y for better debugging.

Only active if NDEBUG is not defined.

Definition at line 125 of file die.hpp.

#define die (   msg)

Instead of std::terminate(), throw the output the message via an exception.

Definition at line 43 of file die.hpp.

#define die_if (   X)

Check condition X and die miserably if true.

Opposite of assert() except this is also active in Release mode.

Definition at line 74 of file die.hpp.

#define die_unequal (   X,
 
)

Check that X == Y or die miserably, but output the values of X and Y for better debugging.

Definition at line 111 of file die.hpp.

#define die_unequal_eps (   X,
  Y,
  eps 
)

Check that ABS(X - Y) <= eps or die miserably, but output the values of X and Y for better debugging.

Definition at line 146 of file die.hpp.

#define die_unequal_eps6 (   X,
 
)

Check that ABS(X - Y) <= 0.000001 or die miserably, but output the values of X and Y for better debugging.

Definition at line 158 of file die.hpp.

#define die_unless (   X)

Check condition X and die miserably if false.

Same as assert() except this is also active in Release mode.

Definition at line 64 of file die.hpp.

#define die_unless_throws (   code,
  exception_type 
)

Define to check that [code] throws and exception of given type.

Definition at line 165 of file die.hpp.

#define die_with_sstream (   msg)

Instead of std::terminate(), throw the output the message via an exception.

Definition at line 34 of file die.hpp.