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 1/3] libstdc++: Separate construct/convertibility tests for std::tuple
Date: Tue, 23 Aug 2022 15:53:02 +0100	[thread overview]
Message-ID: <CACb0b4=8OZoO2qN=TJymLtJuVzfjTgg9ikSZ-XQj=A4NsanFXg@mail.gmail.com> (raw)
In-Reply-To: <6f6c8fa3-26b0-cf5f-0926-7c2dab46b63a@idea>

On Tue, 23 Aug 2022 at 14:44, Patrick Palka <ppalka@redhat.com> wrote:
>
> On Tue, 23 Aug 2022, Jonathan Wakely wrote:
>
> > On Tue, 23 Aug 2022 at 02:35, Patrick Palka via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > P2321R2 adds new conditionally explicit constructors to std::tuple which
> > > we'll concisely implement in a subsequent patch using explicit(bool), like
> > > in our C++20 std::pair implementation.  But before we can do that, this
> > > patch first adds members to _TupleConstraints that test for constructibility
> > > and convertibility separately; we'll use the first in the new constructors'
> > > constraints, and the second in their explicit specifier.
> > >
> > > In passing, this patch also redefines the existing predicates
> > > __is_ex/implicitly_constructible in terms of these new members.  This
> > > seems to reduce compile time and memory usage by about 10% for large
> >
> > Nice.
> >
> > > tuples when using the relevant constructors constrained by
> > > _Explicit/_ImplicitCtor (since we no longer have to redundantly expand
> > > and process is_constructible<_Types, _UTypes>... twice for each pair of
> > > such constructors).  In order to retain maximal short circuiting, do
> > > this only when constexpr if is available.
> >
> > Would we get similar benefits for C++11 and C++14 by doing:
> >
> >        return __and_<__and_<is_constructible<_Types, _UTypes>...>,
> >                      __and_<is_convertible<_UTypes, _Types>...>
> >                      >::value;
> >
> > This is slightly more work in total, but if we have __and_<A,B> and
> > __and_<A,__not_<B>> then the A and B instantiations will be cached and
> > can be reused.
>
> Good idea, it seems we get pretty much the same 10% improvement for
> C++11/14 with this approach.  I reckon we might as well then define
> __convertible and __constructible as alias templates instead of as
> variable templates and use them unconditionally in
> __is_im/explicitly_constructible for benefit of all language versions.

I had a similar thought after hitting send.


> Using constexpr if instead of the outer __and_ seems to yield a marginal
> improvement at best and __and_v is currently just __and_::value, so it
> doesn't seem worth it to have different definitions for C++17 at least
> for now.
>
> What do you think about the following?

OK for trunk - thanks.


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

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  1:34 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
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 [this message]

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='CACb0b4=8OZoO2qN=TJymLtJuVzfjTgg9ikSZ-XQj=A4NsanFXg@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).