public inbox for libstdc++-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-4614] libstdc++: Fix constraint on std::basic_format_string [PR108024] Date: Mon, 12 Dec 2022 14:01:06 +0000 (GMT) [thread overview] Message-ID: <20221212140106.17E753851373@sourceware.org> (raw) https://gcc.gnu.org/g:6c0f9584013dbedeacacb041d40ce9005b902df0 commit r13-4614-g6c0f9584013dbedeacacb041d40ce9005b902df0 Author: Jonathan Wakely <jwakely@redhat.com> Date: Mon Dec 12 11:40:07 2022 +0000 libstdc++: Fix constraint on std::basic_format_string [PR108024] Also remove some redundant std::move calls for return statements. libstdc++-v3/ChangeLog: PR libstdc++/108024 * include/std/format (basic_format_string): Fix constraint. * testsuite/std/format/format_string.cc: New test. Diff: --- libstdc++-v3/include/std/format | 10 ++++++---- libstdc++-v3/testsuite/std/format/format_string.cc | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 269f8f6cc6a..9c928371415 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -110,7 +110,8 @@ namespace __format template<typename _CharT, typename... _Args> struct basic_format_string { - template<convertible_to<basic_string_view<_CharT>> _Tp> + template<typename _Tp> + requires convertible_to<const _Tp&, basic_string_view<_CharT>> consteval basic_format_string(const _Tp& __s); @@ -609,7 +610,7 @@ namespace __format else for (_CharT __c : __str) *__out++ = __c; - return std::move(__out); + return __out; } // Write STR to OUT with NFILL copies of FILL_CHAR specified by ALIGN. @@ -664,7 +665,7 @@ namespace __format __out = __format::__write(std::move(__out), __str); __pad(__r, __out); - return std::move(__out); + return __out; } // A lightweight optional<locale>. @@ -3626,7 +3627,8 @@ namespace __format /// @endcond template<typename _CharT, typename... _Args> - template<convertible_to<basic_string_view<_CharT>> _Tp> + template<typename _Tp> + requires convertible_to<const _Tp&, basic_string_view<_CharT>> consteval basic_format_string<_CharT, _Args...>:: basic_format_string(const _Tp& __s) diff --git a/libstdc++-v3/testsuite/std/format/format_string.cc b/libstdc++-v3/testsuite/std/format/format_string.cc new file mode 100644 index 00000000000..1dd6ca8f125 --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/format_string.cc @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +#include <format> + +struct Str +{ + consteval operator std::string_view() const { return ""; } + operator std::string_view() = delete; +}; + +// PR libstdc++/108024 +static_assert( std::is_constructible_v<std::format_string<>, const Str&> ); +static_assert( std::is_convertible_v<const Str&, std::format_string<>> ); + +constinit std::format_string<> s = Str();
reply other threads:[~2022-12-12 14:01 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=20221212140106.17E753851373@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).