From f5045da9e74ee0378a82a2fb32bc2eb027f37887 Mon Sep 17 00:00:00 2001 From: Denis Popov Date: Wed, 2 Dec 2026 09:20:30 -0800 Subject: [PATCH] fix(headers): replace remaining std::invoke_result with decltype for MSVC 14.52 (#805) Follow-up to upstream PR #794, which converted std::invoke_result_t sites to direct decltype expressions to work around MSVC 14.52 C3539 ('type': a template-argument cannot be a type that contains 'auto'), but missed the remaining typename std::invoke_result<...>::type sites. - Convert field_names_t.hpp (directly hit by rfl::json::read in #805) and drop its unused include. - Convert internal/field_tuple_t.hpp, internal/Field.hpp, internal/flattened_ptr_tuple_t.hpp, and internal/move_from_named_tuple.hpp (also resolving the overloaded nt_to_ptr_named_tuple(std::declval()) call). - Convert the remaining 3 std::invoke_result::type sites in internal/cpp20/Result.hpp and harmonize transform && to decltype(_f(...)) so all 4 monadic overloads match the actual call expression and const&/&& value category. --- include/rfl/field_names_t.hpp | 5 ++--- include/rfl/internal/Field.hpp | 4 ++-- include/rfl/internal/cpp20/Result.hpp | 8 ++++---- include/rfl/internal/field_tuple_t.hpp | 4 ++-- include/rfl/internal/flattened_ptr_tuple_t.hpp | 3 ++- include/rfl/internal/move_from_named_tuple.hpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/rfl/field_names_t.hpp b/include/rfl/field_names_t.hpp index c30ddc585..08bc5f36c 100644 --- a/include/rfl/field_names_t.hpp +++ b/include/rfl/field_names_t.hpp @@ -1,7 +1,6 @@ #ifndef RFL_FIELD_NAMES_T_HPP_ #define RFL_FIELD_NAMES_T_HPP_ -#include #include #include "internal/get_field_names.hpp" @@ -13,8 +12,8 @@ namespace rfl { /// for iteration, validation, or other metaprogramming tasks. /// @tparam T The struct type to extract field names from template -using field_names_t = typename std::invoke_result< - decltype(internal::get_field_names>)>::type; +using field_names_t = + decltype(internal::get_field_names>()); } // namespace rfl diff --git a/include/rfl/internal/Field.hpp b/include/rfl/internal/Field.hpp index 186b12f04..2e3087ad3 100644 --- a/include/rfl/internal/Field.hpp +++ b/include/rfl/internal/Field.hpp @@ -2,6 +2,7 @@ #define RFL_INTERNAL_FIELD_TUPLE_T_HPP_ #include +#include #include "copy_to_field_tuple.hpp" @@ -9,8 +10,7 @@ namespace rfl { namespace internal { template -using field_tuple_t = - typename std::invoke_result), T>::type; +using field_tuple_t = decltype(copy_to_field_tuple(std::declval())); } } // namespace rfl diff --git a/include/rfl/internal/cpp20/Result.hpp b/include/rfl/internal/cpp20/Result.hpp index fb436bedb..a47c2c51d 100644 --- a/include/rfl/internal/cpp20/Result.hpp +++ b/include/rfl/internal/cpp20/Result.hpp @@ -154,7 +154,7 @@ class Result { template auto and_then(const F& _f) && { /// Result_U is expected to be of type Result. - using Result_U = typename std::invoke_result::type; + using Result_U = decltype(_f(std::move(*this).get_t())); if (success_) { return Result_U(_f(std::move(*this).get_t())); } else { @@ -178,7 +178,7 @@ class Result { template auto and_then(const F& _f) const& { /// Result_U is expected to be of type Result. - using Result_U = typename std::invoke_result::type; + using Result_U = decltype(_f(get_t())); if (success_) { return Result_U(_f(get_t())); } else { @@ -335,7 +335,7 @@ class Result { template RFL_ALWAYS_INLINE auto transform(const F& _f) && { /// Result_U is expected to be of type Result. - using U = decltype(std::declval()(std::declval())); + using U = decltype(_f(std::move(*this).get_t())); if (success_) { return Result(_f(std::move(*this).get_t())); } else { @@ -355,7 +355,7 @@ class Result { template auto transform(const F& _f) const& { /// Result_U is expected to be of type Result. - using U = typename std::invoke_result::type; + using U = decltype(_f(get_t())); if (success_) { return Result(_f(get_t())); } else { diff --git a/include/rfl/internal/field_tuple_t.hpp b/include/rfl/internal/field_tuple_t.hpp index bf0e473d4..882937350 100644 --- a/include/rfl/internal/field_tuple_t.hpp +++ b/include/rfl/internal/field_tuple_t.hpp @@ -2,14 +2,14 @@ #define RFL_INTERNAL_FIELD_TUPLE_T_HPP_ #include +#include #include "copy_to_field_tuple.hpp" namespace rfl::internal { template -using field_tuple_t = - typename std::invoke_result), T>::type; +using field_tuple_t = decltype(copy_to_field_tuple(std::declval())); } // namespace rfl::internal diff --git a/include/rfl/internal/flattened_ptr_tuple_t.hpp b/include/rfl/internal/flattened_ptr_tuple_t.hpp index 9c8a3f3cd..11d601a11 100644 --- a/include/rfl/internal/flattened_ptr_tuple_t.hpp +++ b/include/rfl/internal/flattened_ptr_tuple_t.hpp @@ -2,6 +2,7 @@ #define RFL_INTERNAL_FLATTENED_PTR_TUPLE_T_HPP_ #include +#include #include "to_flattened_ptr_tuple.hpp" @@ -10,7 +11,7 @@ namespace internal { template using flattened_ptr_tuple_t = - typename std::invoke_result), T>::type; + decltype(to_flattened_ptr_tuple(std::declval())); } // namespace internal } // namespace rfl diff --git a/include/rfl/internal/move_from_named_tuple.hpp b/include/rfl/internal/move_from_named_tuple.hpp index 617bcb163..51b7cb652 100644 --- a/include/rfl/internal/move_from_named_tuple.hpp +++ b/include/rfl/internal/move_from_named_tuple.hpp @@ -2,6 +2,7 @@ #define RFL_MOVE_FROM_NAMED_TUPLE_HPP_ #include +#include #include "../Tuple.hpp" #include "../named_tuple_t.hpp" @@ -20,8 +21,7 @@ auto make_ptr_fields(PtrNamedTupleType& _n) { using T = std::remove_cvref_t>; if constexpr (is_named_tuple_v) { using SubPtrNamedTupleType = - typename std::invoke_result), - T>::type; + decltype(nt_to_ptr_named_tuple(std::declval())); return SubPtrNamedTupleType(_n).fields(); } else if constexpr (is_flatten_field::value) { using SubPtrFieldTupleType = std::remove_cvref_t>;