![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Definition of various preprocessor macros for error checking. More...
#include <algorithm>Go to the source code of this file.
Macros | |
| #define | CDPL_MATH_CHECK(expr, msg, e) |
Throws the exception e with message msg when the boolean expression expr evaluates to false. More... | |
| #define | CDPL_MATH_CHECK_SIZE_EQUALITY(size1, size2, e) checkSizeEquality<e>(size1, size2) |
Throws the exception e if size1 differs from size2, otherwise returns std::min(size1, size2). More... | |
| #define | CDPL_MATH_CHECK_MAX_SIZE(size, max_size, e) checkMaxSize<e>(size, max_size) |
Throws the exception e if size exceeds max_size, otherwise returns std::min(size, max_size). More... | |
Definition of various preprocessor macros for error checking.
| #define CDPL_MATH_CHECK | ( | expr, | |
| msg, | |||
| e | |||
| ) |
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Expands to an empty statement when the macro CDPL_MATH_CHECKS_DISABLE is defined at compile time, allowing release builds to elide the check.
| expr | The boolean condition that must hold. |
| msg | The C-string error message passed to the exception constructor. |
| e | The exception type to throw when expr is false. |
| #define CDPL_MATH_CHECK_SIZE_EQUALITY | ( | size1, | |
| size2, | |||
| e | |||
| ) | checkSizeEquality<e>(size1, size2) |
Throws the exception e if size1 differs from size2, otherwise returns std::min(size1, size2).
Intended for size compatibility checks (e.g. matching vector dimensions in arithmetic expressions). Subject to compile-time elision via CDPL_MATH_CHECKS_DISABLE (see CDPL_MATH_CHECK).
| size1 | The first size value. |
| size2 | The second size value. |
| e | The exception type to throw on size mismatch. |
| #define CDPL_MATH_CHECK_MAX_SIZE | ( | size, | |
| max_size, | |||
| e | |||
| ) | checkMaxSize<e>(size, max_size) |
Throws the exception e if size exceeds max_size, otherwise returns std::min(size, max_size).
Intended for upper-bound size checks. Subject to compile-time elision via CDPL_MATH_CHECKS_DISABLE.
| size | The size value to test. |
| max_size | The upper bound the size must respect. |
| e | The exception type to throw on overflow. |