public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: 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 13:03:35 +0100	[thread overview]
Message-ID: <CACb0b4n8XFCZ3CGC3Cf1p4AfkCSAWJP7BQ0zFOzSrZrZ53a2=A@mail.gmail.com> (raw)
In-Reply-To: <20220823013500.1756466-2-ppalka@redhat.com>

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.

> @@ -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.


  reply	other threads:[~2022-08-23 12:03 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 [this message]
2022-08-23 15:14     ` Patrick Palka
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='CACb0b4n8XFCZ3CGC3Cf1p4AfkCSAWJP7BQ0zFOzSrZrZ53a2=A@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.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).