From: Jonathan Wakely <jwakely@redhat.com>
To: Ville Voutilainen <ville.voutilainen@gmail.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>
Subject: Re: [RFC] Deprecate non-standard constructors in std::pair
Date: Wed, 7 Apr 2021 19:17:13 +0100 [thread overview]
Message-ID: <20210407181713.GD3008@redhat.com> (raw)
In-Reply-To: <20210407180030.GC3008@redhat.com>
On 07/04/21 19:00 +0100, Jonathan Wakely wrote:
>On 07/04/21 17:59 +0100, Jonathan Wakely wrote:
>>On 07/04/21 13:46 +0100, Jonathan Wakely wrote:
>>>On 07/04/21 15:41 +0300, Ville Voutilainen via Libstdc++ wrote:
>>>>On Wed, 7 Apr 2021 at 15:31, Jonathan Wakely via Libstdc++
>>>><libstdc++@gcc.gnu.org> wrote:
>>>>>I propose that we deprecate the constructors for C++11/14/17/20 in
>>>>>stage 1, and do not support them at all in C++23 mode once P1951 is
>>>>>supported. I have a patch which I'll send in stage 1 (it also uses
>>>>>C++20 concepts to simplify std::pair and fix PR 97930).
>>>>>
>>>>>After a period of deprecation we could remove them, and support P1951
>>>>>for -std=gnu++11/14/17/20 too so that {} continues to work.
>>>>
>>>>The proposal sounds good to me.
>>>
>>>Thanks. I've created https://gcc.gnu.org/PR99957 so I don't forget.
>>
>>Here's a patch to implement it, for stage 1.
>
>
>>diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
>>index 70262f9508f..883d7441b3d 100644
>>--- a/libstdc++-v3/include/bits/stl_pair.h
>>+++ b/libstdc++-v3/include/bits/stl_pair.h
>>@@ -128,34 +128,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> is_convertible<_U2&&, _T2>>::value;
>> }
>>
>>- template <bool __implicit, typename _U1, typename _U2>
>>- static constexpr bool _CopyMovePair()
>>- {
>>- using __do_converts = __and_<is_convertible<const _U1&, _T1>,
>>- is_convertible<_U2&&, _T2>>;
>>- using __converts = typename conditional<__implicit,
>>- __do_converts,
>>- __not_<__do_converts>>::type;
>>- return __and_<is_constructible<_T1, const _U1&>,
>>- is_constructible<_T2, _U2&&>,
>>- __converts
>>- >::value;
>>- }
>>
>> template <bool __implicit, typename _U1, typename _U2>
>>- static constexpr bool _MoveCopyPair()
>>+ static constexpr bool _DeprConsPair()
>> {
>> using __do_converts = __and_<is_convertible<_U1&&, _T1>,
>>- is_convertible<const _U2&, _T2>>;
>>+ is_convertible<_U2&&, _T2>>;
>> using __converts = typename conditional<__implicit,
>>- __do_converts,
>>- __not_<__do_converts>>::type;
>>+ __do_converts,
>>+ __not_<__do_converts>>::type;
>> return __and_<is_constructible<_T1, _U1&&>,
>>- is_constructible<_T2, const _U2&&>,
>>+ is_constructible<_T2, _U2&&>,
>
>N.B. this fixes a bug in the line above, where const _U2&& is used in
>place of const _U2&.
>
>I'll create a testcase that tickles the bug and report it to bugzilla
>tomorrow.
This fails to compile because of that bug:
#include <utility>
struct X {
X(void* = 0) { }
X(const X&) = default;
X(const X&&) = delete;
};
struct move_only {
move_only() = default;
move_only(move_only&&) = default;
};
std::pair<move_only, X> p0(move_only(), 0);
std::pair<move_only, X> p1(move_only(), {});
The pair(U1&&, const T2&) constructor should be viable, but it fails
the _MoveCopyPair constraint check because X(const X&&) is deleted.
I'm not sure I care about this though. It would only work because of
those non-standard constructors which we're talking about deprecating.
I'm not very motivated to fix them so they accept this, when we're
going to deprecate them anyway.
next prev parent reply other threads:[~2021-04-07 18:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 12:30 Jonathan Wakely
2021-04-07 12:41 ` Ville Voutilainen
2021-04-07 12:46 ` Jonathan Wakely
2021-04-07 16:59 ` Jonathan Wakely
2021-04-07 17:18 ` Jonathan Wakely
2021-04-28 16:57 ` Jonathan Wakely
2021-04-28 17:19 ` Jonathan Wakely
2021-04-07 18:00 ` Jonathan Wakely
2021-04-07 18:17 ` Jonathan Wakely [this message]
2021-04-07 18:25 ` Ville Voutilainen
2021-04-07 18:26 ` Ville Voutilainen
2021-04-28 16:57 ` Jonathan Wakely
2021-04-28 17:00 ` Jonathan Wakely
2021-04-28 17:11 ` Jonathan Wakely
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=20210407181713.GD3008@redhat.com \
--to=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=ville.voutilainen@gmail.com \
/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: link
Be 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).