From 5f2a90b0c79ecca2499802d81d7f37709d69fa61 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 10 Jul 2025 16:19:35 -0600 Subject: [PATCH] :bug: Small fixes for `CX_VALUE` and friends Problem: - `CX_VALUE` without a capture clause is important for use cases where the lambda has to be default constructible. - Naming the function type in the `CX_WRAP` macro causes shadowing warnings. Solution: - Remove the default capture clause from `CX_VALUE`. - Leave the function unnamed in `CX_WRAP`. --- include/stdx/utility.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/stdx/utility.hpp b/include/stdx/utility.hpp index 9afcce9..1478f97 100644 --- a/include/stdx/utility.hpp +++ b/include/stdx/utility.hpp @@ -234,7 +234,7 @@ template constexpr auto is_ct_v = is_ct_v; #ifndef CX_VALUE #define CX_VALUE(...) \ - [&]() constexpr { \ + []() constexpr { \ STDX_PRAGMA(diagnostic push) \ STDX_PRAGMA(diagnostic ignored "-Wold-style-cast") \ STDX_PRAGMA(diagnostic ignored "-Wunused-value") \ @@ -274,7 +274,10 @@ template constexpr auto is_ct_v = is_ct_v; }([&] { return X; }) #ifdef __clang__ -#define CX_DETECT(X) std::is_empty_v +#define CX_DETECT(X) \ + std::is_empty_v #else namespace stdx { inline namespace v1 { @@ -290,10 +293,11 @@ constexpr auto cx_detect1(auto) { return 0; } #endif #define CX_WRAP(X) \ - [&](F f) { \ + [&](auto f) { \ STDX_PRAGMA(diagnostic push) \ STDX_PRAGMA(diagnostic ignored "-Wold-style-cast") \ - if constexpr (::stdx::is_cx_value_v>) { \ + if constexpr (::stdx::is_cx_value_v< \ + std::invoke_result_t>) { \ return f(); \ } else if constexpr (CX_DETECT(X)) { \ if constexpr (decltype(::stdx::cxv_detail::is_type< \