public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: Patrick Palka <ppalka@redhat.com>,
	gcc-patches@gcc.gnu.org,  libstdc++@gcc.gnu.org
Subject: Re: [PATCH 2/3] libstdc++: Implement std::pair/tuple/misc enhancements from P2321R2
Date: Tue, 23 Aug 2022 11:14:11 -0400 (EDT)	[thread overview]
Message-ID: <d1b8224d-e5ce-939c-08fd-4311b520766e@idea> (raw)
In-Reply-To: <CACb0b4n8XFCZ3CGC3Cf1p4AfkCSAWJP7BQ0zFOzSrZrZ53a2=A@mail.gmail.com>

On Tue, 23 Aug 2022, Jonathan Wakely wrote:

> On Tue, 23 Aug 2022 at 02:36, Patrick Palka via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> > --- a/libstdc++-v3/include/bits/stl_pair.h
> > +++ b/libstdc++-v3/include/bits/stl_pair.h
> > @@ -212,6 +212,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >         swap(second, __p.second);
> >        }
> >
> > +#if __cplusplus > 202002L
> > +      /// Swap the first members and then the second members.
> > +      constexpr void
> > +      swap(const pair& __p) const
> > +      noexcept(__and_<__is_nothrow_swappable<const _T1>,
> > +                     __is_nothrow_swappable<const _T2>>::value)
> 
> This could use __and_v (which is just __and_::value today, but could
> theoretically be optimized to use a requires expression and avoid
> instantiating __and_ one day).
> 
> Is consistency with the C++11 overload more important? I *hope* we
> won't need to make many changes to these noexcept-specifiers, so the
> maintenance burden of using __ad_::value in one and __and_v in the
> other shouldn't be too high.

Makes sense.

> 
> > @@ -710,6 +792,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >      noexcept(noexcept(__x.swap(__y)))
> >      { __x.swap(__y); }
> >
> > +#if __cplusplus > 202002L
> > +  template<typename _T1, typename _T2>
> > +    requires is_swappable<const _T1>::value && is_swappable<const _T2>::value
> 
> is_swappable_v instead of ::value here ... this is already using a
> requires-clause and so is substantially different to the old overload
> anyway.
> 
> 
> 
> > +
> >        // tuple swap
> >        _GLIBCXX20_CONSTEXPR
> >        void
> >        swap(tuple& __in)
> >        noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
> >        { _Inherited::_M_swap(__in); }
> > +
> > +#if __cplusplus > 202002L
> > +      constexpr void
> > +      swap(const tuple& __in) const
> > +      noexcept(__and_<__is_nothrow_swappable<const _Elements>...>::value)
> 
> __and_v ?
> 
> 
> 
> 
> >        _GLIBCXX20_CONSTEXPR
> >        void
> >        swap(tuple& __in)
> >        noexcept(__and_<__is_nothrow_swappable<_T1>,
> >                       __is_nothrow_swappable<_T2>>::value)
> >        { _Inherited::_M_swap(__in); }
> > +
> > +#if __cplusplus > 202002L
> > +      constexpr void
> > +      swap(const tuple& __in) const
> > +      noexcept(__and_<__is_nothrow_swappable<const _T1>,
> > +                     __is_nothrow_swappable<const _T2>>::value)
> 
> __and_v ?
> 
> 
> Thanks for doing this, those changes looked tedious to implement and test!
> 
> If you agree with the suggestions to use _v variable templates, this
> is OK for trunk with those changes. I am willing to be persuaded to
> not use the variable templates if there's a good reason I've missed.

Agreed on all points!  Thanks a lot.


  reply	other threads:[~2022-08-23 15:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  1:34 [PATCH 1/3] libstdc++: Separate construct/convertibility tests for std::tuple Patrick Palka
2022-08-23  1:34 ` [PATCH 2/3] libstdc++: Implement std::pair/tuple/misc enhancements from P2321R2 Patrick Palka
2022-08-23 12:03   ` Jonathan Wakely
2022-08-23 15:14     ` Patrick Palka [this message]
2022-08-23  1:35 ` [PATCH 3/3] libstdc++: Implement ranges::zip_view " Patrick Palka
2022-08-24 12:15   ` Jonathan Wakely
2022-08-26 20:05   ` Jonathan Wakely
2022-08-31 10:12     ` Jonathan Wakely
2022-08-23  9:15 ` [PATCH 1/3] libstdc++: Separate construct/convertibility tests for std::tuple Jonathan Wakely
2022-08-23 13:44   ` Patrick Palka
2022-08-23 14:53     ` 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=d1b8224d-e5ce-939c-08fd-4311b520766e@idea \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@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: 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).