From de17ac3dc5394c44d957ec1a51fcc3f66c4e2021 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Fri, 11 Jul 2025 14:07:27 -0600 Subject: [PATCH] :bug: Fix `STATIC_ASSERT` capture spec Problem: - Sometimes, `STATIC_ASSERT` may need to capture variables. Solution: - Use `[&]` as the capture spec in the `STATIC_ASSERT` lambda expressions. --- include/stdx/static_assert.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/stdx/static_assert.hpp b/include/stdx/static_assert.hpp index 958498b..71d90e7 100644 --- a/include/stdx/static_assert.hpp +++ b/include/stdx/static_assert.hpp @@ -29,7 +29,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") \ @@ -43,7 +43,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::ct_check.template emit(); \ return B; \