From d9481b552c2d44a14615b79b950468dc46847da0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 10 Jul 2024 23:00:00 +0200 Subject: [PATCH] crnlib: implement CRNLIB_ASSUME with static_assert --- crnlib/crn_assert.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/crnlib/crn_assert.h b/crnlib/crn_assert.h index 152a6a19..8cd8250a 100644 --- a/crnlib/crn_assert.h +++ b/crnlib/crn_assert.h @@ -29,25 +29,7 @@ void crnlib_fail(const char* pExp, const char* pFile, unsigned line); void trace(const char* pFmt, va_list args); void trace(const char* pFmt, ...); -// Borrowed from boost libraries. -template -struct crnlib_assume_failure; -template <> -struct crnlib_assume_failure { - enum { blah = 1 }; -}; -template -struct crnlib_assume_try {}; - -#define CRNLIB_JOINER_FINAL(a, b) a##b -#define CRNLIB_JOINER(a, b) CRNLIB_JOINER_FINAL(a, b) -#define CRNLIB_JOIN(a, b) CRNLIB_JOINER(a, b) - -#ifdef NDEBUG -#define CRNLIB_ASSUME(p) -#else -#define CRNLIB_ASSUME(p) typedef crnlib_assume_try)> CRNLIB_JOIN(crnlib_assume_typedef, __COUNTER__) -#endif +#define CRNLIB_ASSUME(p) static_assert(p, "") #ifdef NDEBUG template