From 49f6efdc3fbfaac66599f99b52eeab1b99ff1153 Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Sun, 5 Dec 2021 16:24:23 -0500 Subject: [PATCH 1/2] Fix compilation under Clang Fixes #1069 --- cppwinrt/code_writers.h | 3 ++- cppwinrt/cppwinrt.vcxproj | 3 ++- cppwinrt/cppwinrt.vcxproj.filters | 3 +++ strings/base_stringable_format.h | 12 ++++-------- strings/base_stringable_format_1.h | 9 +++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 strings/base_stringable_format_1.h diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h index c369eb98c..9d4b98e23 100644 --- a/cppwinrt/code_writers.h +++ b/cppwinrt/code_writers.h @@ -3259,6 +3259,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable w.write(strings::base_reference_produce); w.write(strings::base_deferral); w.write(strings::base_coroutine_foundation); + w.write(strings::base_stringable_format); } else if (namespace_name == "Windows.Foundation.Collections") { @@ -3295,7 +3296,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable if (namespace_name == "Windows.Foundation") { w.write(strings::base_reference_produce_1); - w.write(strings::base_stringable_format); + w.write(strings::base_stringable_format_1); } } } diff --git a/cppwinrt/cppwinrt.vcxproj b/cppwinrt/cppwinrt.vcxproj index 71272d14f..258feafc6 100644 --- a/cppwinrt/cppwinrt.vcxproj +++ b/cppwinrt/cppwinrt.vcxproj @@ -79,9 +79,10 @@ + - + diff --git a/cppwinrt/cppwinrt.vcxproj.filters b/cppwinrt/cppwinrt.vcxproj.filters index bfd56434a..dfe1488ee 100644 --- a/cppwinrt/cppwinrt.vcxproj.filters +++ b/cppwinrt/cppwinrt.vcxproj.filters @@ -169,6 +169,9 @@ strings + + strings + strings diff --git a/strings/base_stringable_format.h b/strings/base_stringable_format.h index 41a54dfd4..f66c21003 100644 --- a/strings/base_stringable_format.h +++ b/strings/base_stringable_format.h @@ -1,12 +1,8 @@ #ifdef __cpp_lib_format -template<> -struct std::formatter : std::formatter +template +WINRT_IMPL_AUTO(void) std::formatter::format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) { - template - auto format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) - { - return std::formatter::format(obj.ToString(), fc); - } -}; + return std::formatter::format(obj.ToString(), fc); +} #endif diff --git a/strings/base_stringable_format_1.h b/strings/base_stringable_format_1.h new file mode 100644 index 000000000..c27f5338c --- /dev/null +++ b/strings/base_stringable_format_1.h @@ -0,0 +1,9 @@ + +#ifdef __cpp_lib_format +template <> +struct std::formatter : std::formatter +{ + template + WINRT_IMPL_AUTO(void) format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc); +}; +#endif From 6592bba90271e51f7f75567894ec26227adfc076 Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Sun, 5 Dec 2021 16:27:59 -0500 Subject: [PATCH 2/2] Keep normal auto --- strings/base_stringable_format.h | 2 +- strings/base_stringable_format_1.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/strings/base_stringable_format.h b/strings/base_stringable_format.h index f66c21003..86c5acfc6 100644 --- a/strings/base_stringable_format.h +++ b/strings/base_stringable_format.h @@ -1,7 +1,7 @@ #ifdef __cpp_lib_format template -WINRT_IMPL_AUTO(void) std::formatter::format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) +auto std::formatter::format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) { return std::formatter::format(obj.ToString(), fc); } diff --git a/strings/base_stringable_format_1.h b/strings/base_stringable_format_1.h index c27f5338c..6a7becdfc 100644 --- a/strings/base_stringable_format_1.h +++ b/strings/base_stringable_format_1.h @@ -4,6 +4,6 @@ template <> struct std::formatter : std::formatter { template - WINRT_IMPL_AUTO(void) format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc); + auto format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc); }; #endif