diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-03-21 11:15:06 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-03-23 11:07:57 +0000 |
commit | 543585046d17add37c0108b06d2884d0e03cedde (patch) | |
tree | 834ee3ae39143ee53af82e424d13d02a0603b654 /libstdc++-v3/include | |
parent | 3763fb8970d7515a4a3be2152604140965303031 (diff) | |
download | gcc-543585046d17add37c0108b06d2884d0e03cedde.zip gcc-543585046d17add37c0108b06d2884d0e03cedde.tar.gz gcc-543585046d17add37c0108b06d2884d0e03cedde.tar.bz2 |
libstdc++: Disable std::formatter specializations (LWG 3944)
This was just approved in Tokyo as a DR for C++23. It doesn't affect us
yet, because we don't implement the __cpp_lib_format_ranges features. We
can add the disabled specializations and add a testcase now though.
libstdc++-v3/ChangeLog:
* include/std/format (formatter): Disable specializations that
would allow sequences of narrow characters to be formatted as
wchar_t without conversion, as per LWG 3944.
* testsuite/std/format/formatter/lwg3944.cc: New test.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/std/format | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 613016d..22dcb5f 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -2478,6 +2478,29 @@ namespace __format }; /// @} +#if defined _GLIBCXX_USE_WCHAR_T && __cpp_lib_format_ranges + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3944. Formatters converting sequences of char to sequences of wchar_t + + namespace __format { struct __disabled; } + + // std::formatter<__disabled, C> uses the primary template, which is disabled. + template<> + struct formatter<char*, wchar_t> + : private formatter<__format::__disabled, wchar_t> { }; + template<> + struct formatter<const char*, wchar_t> + : private formatter<__format::__disabled, wchar_t> { }; + template<size_t _Nm> + struct formatter<char[_Nm], wchar_t> + : private formatter<__format::__disabled, wchar_t> { }; + template<class _Traits, class _Allocator> + struct formatter<basic_string<char, _Traits, _Allocator>, wchar_t> + : private formatter<__format::__disabled, wchar_t> { }; + template<class _Traits> + struct formatter<basic_string_view<char, _Traits>, wchar_t> + : private formatter<__format::__disabled, wchar_t> { }; +#endif /// @cond undocumented namespace __format |