From 38be74aa26770ed745fbbae5a999c6a1fea34ef1 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Mon, 9 Sep 2024 10:18:38 -0700 Subject: [PATCH] [0.73] C++ 20: Fix `Explicit template specialization cannot have a storage class` (#12328) (#13681) * C++ 20: Fix `Explicit template specialization cannot have a storage class` (#12328) * C++ 20: Fix "Explicit template specialization cannot have a storage class" Fixes "[Explicit template specialization cannot have a storage class](https://stackoverflow.com/questions/29041775/explicit-template-specialization-cannot-have-a-storage-class-member-method-spe)" in C++ 20 by moving a function outside of a struct. * Change files * Update change file type --- ...-39577653-1e51-4a5f-899b-b34e2da6d70f.json | 7 +++++ .../Microsoft.ReactNative.Cxx/NativeModules.h | 30 +++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 change/react-native-windows-39577653-1e51-4a5f-899b-b34e2da6d70f.json diff --git a/change/react-native-windows-39577653-1e51-4a5f-899b-b34e2da6d70f.json b/change/react-native-windows-39577653-1e51-4a5f-899b-b34e2da6d70f.json new file mode 100644 index 00000000000..f19cec5485f --- /dev/null +++ b/change/react-native-windows-39577653-1e51-4a5f-899b-b34e2da6d70f.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "C++ 20: Fix \"Explicit template specialization cannot have a storage class\"", + "packageName": "react-native-windows", + "email": "ngerlem@fb.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative.Cxx/NativeModules.h b/vnext/Microsoft.ReactNative.Cxx/NativeModules.h index 77cd04a5233..cff77c5c1d2 100644 --- a/vnext/Microsoft.ReactNative.Cxx/NativeModules.h +++ b/vnext/Microsoft.ReactNative.Cxx/NativeModules.h @@ -356,6 +356,21 @@ struct MethodSignatureMatchResult { bool IsSucceeded; }; +template +constexpr bool MatchInputArg() noexcept { + return std::is_same_v; +} + +template <> +constexpr bool MatchInputArg() noexcept { + return true; +} + +template <> +constexpr bool MatchInputArg() noexcept { + return true; +} + template struct MethodSignature { using Result = TResult; @@ -375,21 +390,6 @@ struct MethodSignature { } } - template - static constexpr bool MatchInputArg() noexcept { - return std::is_same_v; - } - - template <> - static constexpr bool MatchInputArg() noexcept { - return true; - } - - template <> - static constexpr bool MatchInputArg() noexcept { - return true; - } - template static constexpr bool MatchInputArgs(std::index_sequence) noexcept { return (MatchInputArg, std::tuple_element_t>() && ...);