@@ -550,10 +550,38 @@ namespace winrt::impl
550
550
auto end = std::copy (std::begin (temp), result.ptr , buffer);
551
551
return hstring{ std::wstring_view{ buffer, static_cast <std::size_t >(end - buffer)} };
552
552
}
553
+
554
+ #if __cpp_lib_format >= 202207L
555
+ template <typename ... Args>
556
+ inline hstring base_format (Args&&... args)
557
+ {
558
+ auto const size = std::formatted_size (args...);
559
+ WINRT_ASSERT (size < UINT_MAX);
560
+ auto const size32 = static_cast <uint32_t >(size);
561
+
562
+ hstring_builder builder (size32);
563
+ WINRT_VERIFY_ (size32, std::format_to_n (builder.data (), size32, args...).size );
564
+ return builder.to_hstring ();
565
+ }
566
+ #endif
553
567
}
554
568
555
569
WINRT_EXPORT namespace winrt
556
570
{
571
+ #if __cpp_lib_format >= 202207L
572
+ template <typename ... Args>
573
+ inline hstring format (std::wformat_string<Args...> const fmt, Args&&... args)
574
+ {
575
+ return impl::base_format (fmt, args...);
576
+ }
577
+
578
+ template <typename ... Args>
579
+ inline hstring format (std::locale const & loc, std::wformat_string<Args...> const fmt, Args&&... args)
580
+ {
581
+ return impl::base_format (loc, fmt, args...);
582
+ }
583
+ #endif
584
+
557
585
inline bool embedded_null (hstring const & value) noexcept
558
586
{
559
587
return std::any_of (value.begin (), value.end (), [](auto item)
0 commit comments