|
79 | 79 | #define LIBASSERT_STRINGIFY(x) #x, |
80 | 80 | #define LIBASSERT_COMMA , |
81 | 81 |
|
82 | | -// Church boolean |
83 | | -#define LIBASSERT_IF(b) LIBASSERT_IF_##b |
84 | | -#define LIBASSERT_IF_true(t,...) t |
85 | | -#define LIBASSERT_IF_false(t,f,...) f |
86 | | - |
87 | 82 | #if LIBASSERT_IS_CLANG || LIBASSERT_IS_GCC |
88 | 83 | #if LIBASSERT_IS_GCC |
89 | 84 | #define LIBASSERT_EXPRESSION_DECOMP_WARNING_PRAGMA_GCC \ |
@@ -280,7 +275,7 @@ LIBASSERT_END_NAMESPACE |
280 | 275 | } |
281 | 276 | LIBASSERT_END_NAMESPACE |
282 | 277 | #endif |
283 | | -#define LIBASSERT_INVOKE_VAL(expr, doreturn, check_expression, name, type, failaction, ...) \ |
| 278 | +#define LIBASSERT_INVOKE_VAL(expr, check_expression, name, type, failaction, ...) \ |
284 | 279 | /* must push/pop out here due to nasty clang bug https://github.com/llvm/llvm-project/issues/63897 */ \ |
285 | 280 | /* must do awful stuff to workaround differences in where gcc and clang allow these directives to go */ \ |
286 | 281 | LIBASSERT_WARNING_PRAGMA_PUSH_CLANG \ |
@@ -327,11 +322,10 @@ LIBASSERT_END_NAMESPACE |
327 | 322 | /* https://timsong-cpp.github.io/cppwp/n4659/basic.life#8.3 */ \ |
328 | 323 | /* Note: Somewhat relying on this call being inlined so inefficiency is eliminated */ \ |
329 | 324 | libassert::detail::get_expression_return_value< \ |
330 | | - doreturn LIBASSERT_COMMA \ |
331 | 325 | libassert_ret_lhs LIBASSERT_COMMA \ |
332 | 326 | std::is_lvalue_reference_v<decltype(libassert_value)> \ |
333 | 327 | >(libassert_value, *std::launder(&libassert_decomposer)); \ |
334 | | - ) LIBASSERT_IF(doreturn)(.value,) \ |
| 328 | + ).value \ |
335 | 329 | LIBASSERT_WARNING_PRAGMA_POP_CLANG |
336 | 330 |
|
337 | 331 | #ifdef NDEBUG |
@@ -369,14 +363,14 @@ LIBASSERT_END_NAMESPACE |
369 | 363 | // value variants |
370 | 364 |
|
371 | 365 | #ifndef NDEBUG |
372 | | - #define LIBASSERT_DEBUG_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, true, "DEBUG_ASSERT_VAL", debug_assertion, , __VA_ARGS__) |
| 366 | + #define LIBASSERT_DEBUG_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, "DEBUG_ASSERT_VAL", debug_assertion, , __VA_ARGS__) |
373 | 367 | #else |
374 | | - #define LIBASSERT_DEBUG_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, false, "DEBUG_ASSERT_VAL", debug_assertion, , __VA_ARGS__) |
| 368 | + #define LIBASSERT_DEBUG_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, false, "DEBUG_ASSERT_VAL", debug_assertion, , __VA_ARGS__) |
375 | 369 | #endif |
376 | 370 |
|
377 | | -#define LIBASSERT_ASSUME_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, true, "ASSUME_VAL", assumption, LIBASSERT_ASSUME_ACTION, __VA_ARGS__) |
| 371 | +#define LIBASSERT_ASSUME_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, "ASSUME_VAL", assumption, LIBASSERT_ASSUME_ACTION, __VA_ARGS__) |
378 | 372 |
|
379 | | -#define LIBASSERT_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, true, "ASSERT_VAL", assertion, , __VA_ARGS__) |
| 373 | +#define LIBASSERT_ASSERT_VAL(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, "ASSERT_VAL", assertion, , __VA_ARGS__) |
380 | 374 |
|
381 | 375 | // non-prefixed versions |
382 | 376 |
|
@@ -415,14 +409,14 @@ LIBASSERT_END_NAMESPACE |
415 | 409 |
|
416 | 410 | #ifdef LIBASSERT_LOWERCASE |
417 | 411 | #ifndef NDEBUG |
418 | | - #define debug_assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, true, "debug_assert_val", debug_assertion, , __VA_ARGS__) |
| 412 | + #define debug_assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, "debug_assert_val", debug_assertion, , __VA_ARGS__) |
419 | 413 | #else |
420 | | - #define debug_assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, false, "debug_assert_val", debug_assertion, , __VA_ARGS__) |
| 414 | + #define debug_assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, false, "debug_assert_val", debug_assertion, , __VA_ARGS__) |
421 | 415 | #endif |
422 | 416 | #endif |
423 | 417 |
|
424 | 418 | #ifdef LIBASSERT_LOWERCASE |
425 | | - #define assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, true, "assert_val", assertion, , __VA_ARGS__) |
| 419 | + #define assert_val(expr, ...) LIBASSERT_INVOKE_VAL(expr, true, "assert_val", assertion, , __VA_ARGS__) |
426 | 420 | #endif |
427 | 421 |
|
428 | 422 | // Wrapper macro to allow support for C++26's user generated static_assert messages. |
|
0 commit comments