diff --git a/include/stdx/static_assert.hpp b/include/stdx/static_assert.hpp index 5fe2c14..7f3be39 100644 --- a/include/stdx/static_assert.hpp +++ b/include/stdx/static_assert.hpp @@ -31,7 +31,7 @@ template constexpr auto ct_check = ct_check_t{}; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define STATIC_ASSERT(cond, ...) \ - [&]() -> bool { \ + []() -> bool { \ STDX_PRAGMA(diagnostic push) \ STDX_PRAGMA(diagnostic ignored "-Wunknown-warning-option") \ STDX_PRAGMA(diagnostic ignored "-Wc++26-extensions") \ @@ -45,7 +45,7 @@ template constexpr auto ct_check = ct_check_t{}; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define STATIC_ASSERT(cond, ...) \ - [&]() -> bool { \ + []() -> bool { \ constexpr auto S = STDX_CT_FORMAT(__VA_ARGS__); \ stdx::detail::ct_check.template emit(); \ return B; \ diff --git a/test/fail/static_assert.cpp b/test/fail/static_assert.cpp index 794d18e..f66f6b5 100644 --- a/test/fail/static_assert.cpp +++ b/test/fail/static_assert.cpp @@ -5,6 +5,8 @@ constexpr auto msg = stdx::ct_string{"01234567890123456789012345678901234567890123456789"}; +static_assert(STATIC_ASSERT(true, "not emitted")); + auto main() -> int { static_assert(STATIC_ASSERT(true, "not emitted")); STATIC_ASSERT(false, msg); diff --git a/test/fail/static_assert_format.cpp b/test/fail/static_assert_format.cpp index 431349d..1fdc859 100644 --- a/test/fail/static_assert_format.cpp +++ b/test/fail/static_assert_format.cpp @@ -3,6 +3,8 @@ // EXPECT: hello world int 123 +static_assert(STATIC_ASSERT(true, "hello {} {} {}", "world", int, 42)); + template constexpr auto f() { STATIC_ASSERT(false, "hello {} {} {}", "world", T, 123); }