Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #pragma once
00012 #ifndef _SBIA_BASIS_ASSERT_H
00013 #define _SBIA_BASIS_ASSERT_H
00014
00015
00016 #include <iostream>
00017 #include <cstdlib>
00018
00019
00020 #ifdef assert
00021 # undef assert
00022 #endif
00023 #ifdef ASSERT
00024 # undef ASSERT
00025 #endif
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef NDEBUG
00040 # define assert(condition) \
00041 do { \
00042 if (!(condition)) { \
00043 ::std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
00044 << " line " << __LINE__ << ::std::endl; \
00045 ::std::exit(EXIT_FAILURE); \
00046 } \
00047 } while (false)
00048 #else
00049 # define assert(condition) do { } while (false)
00050 #endif
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #ifndef NDEBUG
00066 # define ASSERT(condition, message) \
00067 do { \
00068 if (!(condition)) { \
00069 ::std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
00070 << " line " << __LINE__ << ": " << message << ::std::endl; \
00071 ::std::exit(EXIT_FAILURE); \
00072 } \
00073 } while (false)
00074 #else
00075 # define ASSERT(condition, message) do { } while (false)
00076 #endif
00077
00078
00079 #endif // _SBIA_BASIS_ASSERT_H