Skip to content

Commit d9481b5

Browse files
committed
crnlib: implement CRNLIB_ASSUME with static_assert
1 parent 7415db0 commit d9481b5

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

Diff for: crnlib/crn_assert.h

+1-19
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,7 @@ void crnlib_fail(const char* pExp, const char* pFile, unsigned line);
2929
void trace(const char* pFmt, va_list args);
3030
void trace(const char* pFmt, ...);
3131

32-
// Borrowed from boost libraries.
33-
template <bool x>
34-
struct crnlib_assume_failure;
35-
template <>
36-
struct crnlib_assume_failure<true> {
37-
enum { blah = 1 };
38-
};
39-
template <int x>
40-
struct crnlib_assume_try {};
41-
42-
#define CRNLIB_JOINER_FINAL(a, b) a##b
43-
#define CRNLIB_JOINER(a, b) CRNLIB_JOINER_FINAL(a, b)
44-
#define CRNLIB_JOIN(a, b) CRNLIB_JOINER(a, b)
45-
46-
#ifdef NDEBUG
47-
#define CRNLIB_ASSUME(p)
48-
#else
49-
#define CRNLIB_ASSUME(p) typedef crnlib_assume_try<sizeof(crnlib_assume_failure<(bool)(p)>)> CRNLIB_JOIN(crnlib_assume_typedef, __COUNTER__)
50-
#endif
32+
#define CRNLIB_ASSUME(p) static_assert(p, "")
5133

5234
#ifdef NDEBUG
5335
template <typename T>

0 commit comments

Comments
 (0)