diff options
author | Mehdi Goli <mehdi.goli@codeplay.com> | 2018-08-01 12:19:14 +0100 |
---|---|---|
committer | Mehdi Goli <mehdi.goli@codeplay.com> | 2018-08-01 12:19:14 +0100 |
commit | 3a197a60e602ea0cd836438ab717810803dc9074 (patch) | |
tree | c587b06a814b45643e0d8980c2c90c294cc83e08 /Eigen/src/Core/util/Macros.h | |
parent | edf46bd7a27ef1088efc2116196c088d59d22b4a (diff) |
variadic version of assert which can take a parameter pack as its input.
Diffstat (limited to 'Eigen/src/Core/util/Macros.h')
-rw-r--r-- | Eigen/src/Core/util/Macros.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index b15819f7d..3255b8351 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -1076,4 +1076,28 @@ namespace Eigen { # endif #endif +#ifdef EIGEN_HAS_VARIADIC_TEMPLATES +// Provide a variadic version of assert which can take a parameter pack as its input +// The eigen_assert macro used here might have been redefined to use other macros such as EIGEN_THROW, such as used in Eigen's test suite, therefore this needs to be defined after the other macros. +// Note that this does not provide as nice a string to assert as a straight forward call to eigen_assert, so we add a message to the assert. +#if defined(EIGEN_NO_DEBUG) +#define eigen_variadic_assert(x) +#else +namespace Eigen { +namespace internal { +inline void variadic_assert(const char*) {} +template<typename... Bools> inline void variadic_assert(const char* message, bool first, Bools ... others) { + eigen_assert(first && message); + variadic_assert(message, others...); + EIGEN_UNUSED_VARIABLE(first); +} +} +} +#define EIGEN_VARIADIC_ASSERT_MESSAGE(x) EIGEN_MAKESTRING(x) " in " __FILE__ ":" EIGEN_MAKESTRING(__LINE__) +#define eigen_variadic_assert(x) \ + do { Eigen::internal::variadic_assert(EIGEN_VARIADIC_ASSERT_MESSAGE(x), x); } while(false); +#endif +#endif + + #endif // EIGEN_MACROS_H |