public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-8130] libstdc++: Disable std::formatter::set_debug_format [PR112832] Date: Wed, 6 Dec 2023 14:44:41 +0000 (GMT) [thread overview] Message-ID: <20231206144441.742113861837@sourceware.org> (raw) https://gcc.gnu.org/g:d40796e3813fdf646ca7b7ce9630d5cc121353b4 commit r13-8130-gd40796e3813fdf646ca7b7ce9630d5cc121353b4 Author: Jonathan Wakely <jwakely@redhat.com> Date: Mon Dec 4 12:03:28 2023 +0000 libstdc++: Disable std::formatter::set_debug_format [PR112832] All set_debug_format member functions should be guarded by the __cpp_lib_formatting_ranges macro (which is not defined yet). libstdc++-v3/ChangeLog: PR libstdc++/112832 * include/std/format (formatter::set_debug_format): Ensure this member is defined conditionally for all specializations. * testsuite/std/format/formatter/112832.cc: New test. (cherry picked from commit 3cd73543a1122d3c81409e3e9a26c3e94c3d324f) Diff: --- libstdc++-v3/include/std/format | 8 ++++++ .../testsuite/std/format/formatter/112832.cc | 29 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 17ebae676e9..a48bb2e161d 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -1823,9 +1823,11 @@ namespace __format return _M_f.format(__u, __fc); } +#if __cpp_lib_format_ranges constexpr void set_debug_format() noexcept { _M_f._M_spec._M_type = __format::_Pres_esc; } +#endif private: __format::__formatter_int<wchar_t> _M_f; @@ -1850,7 +1852,9 @@ namespace __format format(_CharT* __u, basic_format_context<_Out, _CharT>& __fc) const { return _M_f.format(__u, __fc); } +#if __cpp_lib_format_ranges constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); } +#endif private: __format::__formatter_str<_CharT> _M_f; @@ -1873,7 +1877,9 @@ namespace __format basic_format_context<_Out, _CharT>& __fc) const { return _M_f.format(__u, __fc); } +#if __cpp_lib_format_ranges constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); } +#endif private: __format::__formatter_str<_CharT> _M_f; @@ -1895,7 +1901,9 @@ namespace __format basic_format_context<_Out, _CharT>& __fc) const { return _M_f.format({__u, _Nm}, __fc); } +#if __cpp_lib_format_ranges constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); } +#endif private: __format::__formatter_str<_CharT> _M_f; diff --git a/libstdc++-v3/testsuite/std/format/formatter/112832.cc b/libstdc++-v3/testsuite/std/format/formatter/112832.cc new file mode 100644 index 00000000000..9aa2095a73d --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/formatter/112832.cc @@ -0,0 +1,29 @@ +// { dg-do compile { target c++20 } } + +#include <format> + +template<typename T, + typename C = std::remove_cvref_t<decltype(std::declval<T&>()[0])>> +constexpr bool +test_pr112832() +{ + std::formatter<T, C> f; + if constexpr (requires{ f.set_debug_format(); }) + f.set_debug_format(); + return true; +} + +int main() +{ + static_assert(test_pr112832<std::string_view>()); + static_assert(test_pr112832<char*>()); + static_assert(test_pr112832<const char*>()); + static_assert(test_pr112832<char[1]>()); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_pr112832<std::wstring_view>()); + static_assert(test_pr112832<wchar_t*>()); + static_assert(test_pr112832<const wchar_t*>()); + static_assert(test_pr112832<wchar_t[1]>()); + static_assert(test_pr112832<char, wchar_t>()); +#endif +}
reply other threads:[~2023-12-06 14:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231206144441.742113861837@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).