public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/100070] Standard library container iterator-pair constructors should check C++20 iterator concepts
Date: Wed, 14 Apr 2021 17:34:17 +0000	[thread overview]
Message-ID: <bug-100070-4-leoY26CPFX@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100070-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100070

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #7)
> Note to self/Patrick:
> 
> Measure whether it helps to specialize transform_view's iterator so that
> when _Base_iter is __normal_iterator we unwrap it and store a raw pointer.
> 
> Also, I suspect the indirections in
> 
>   return std::__invoke(*_M_parent->_M_fun, *_M_current);
> 
> are making the optimizer give up.
> 
> We have an indirection to the parent to access the semi-regular box, which
> has its own indirections. Maybe we could just get rid of the semi-regular
> box for a function pointer and store a function pointer (i.e. decay_t<Fp>)
> directly.
> 
> And maybe store a function pointer directly in the transform_view iterator,
> so we don't need to go to the parent to get it on every dereference.

Makes sense to me.  I think we could then get rid of the iterator's _M_parent
data member since it's used only to access the transformation function.  And
doing so would also reduce the size of the iterator in the case where the
transformation function is an empty functor (and so [[no_unique_address]] could
optimize away its storage).

> 
> Barry pointed out that range-v3 elides the use of semi-regular box for some
> cases, and he confirmed that storing a function pointer in the iterator
> helps.

FWIW we already elide the semiregular box for types which are semiregular, via
a partial specialization of __box that is just a [[no_unique_wrapper]] for the
underlying semiregular type.

  parent reply	other threads:[~2021-04-14 17:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 21:34 [Bug c++/100070] New: " barry.revzin at gmail dot com
2021-04-13 21:41 ` [Bug libstdc++/100070] " redi at gcc dot gnu.org
2021-04-13 21:48 ` redi at gcc dot gnu.org
2021-04-13 22:11 ` redi at gcc dot gnu.org
2021-04-13 22:15 ` redi at gcc dot gnu.org
2021-04-14 11:09 ` redi at gcc dot gnu.org
2021-04-14 11:10 ` redi at gcc dot gnu.org
2021-04-14 11:23 ` redi at gcc dot gnu.org
2021-04-14 16:41 ` redi at gcc dot gnu.org
2021-04-14 17:34 ` ppalka at gcc dot gnu.org [this message]
2021-10-12 21:50 ` ppalka at gcc dot gnu.org
2021-10-12 22:56 ` redi at gcc dot gnu.org
2022-04-22 17:33 ` redi at gcc dot gnu.org

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=bug-100070-4-leoY26CPFX@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).