public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Remove lambdas from _Rb_tree
Date: Fri, 20 Nov 2020 10:22:59 +0000	[thread overview]
Message-ID: <20201120102259.GK1312820@redhat.com> (raw)
In-Reply-To: <616cd512-76cd-5d7c-0a9b-7224816bc245@gmail.com>

On 20/11/20 08:17 +0100, François Dumont via Libstdc++ wrote:
>Here is what I am testing.
>
>I use your enum proposal as an alias for the bool type. I cannot use 
>it as template parameter on _M_copy unless I put it at std namespace 
>level to use it in definition of the outline _M_copy overload.

You can do it as a member, but the syntax is ugly:

   template<typename _Key, typename _Val, typename _KoV,
          typename _Compare, typename _Alloc>
     template<typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_CopyType _MoveValues, typename _NodeGen>
       typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
       _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
       _M_copy(_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen)





>I also added some tests checking correct usage of 
>__move_if_noexcept_cond. I prefer not to change this condition as 
>proposed in this patch.

Yes, we can do that later if needed.

>I wonder if I am right to check moved values in those tests ?

Yes, I think that's good.

>I also wonder after writing those tests if we shouldn't clear the 
>moved instance, especially when values are moved ? I remember seeing 
>some discussion about this but I don't know the conclusion.

It's not required to clear them.

Leaving them with moved-from values means the memory isn't
deallocated, and those nodes can be reused if the container gets
assigned new values.

>    libstdc++: _Rb_tree code cleanup, remove lambdas
>
>    Use new template parameters to replace usage of lambdas to move or not
>    tree values on copy.
>
>    libstdc++-v3/ChangeLog:
>
>            * include/bits/move.h (_GLIBCXX_FWDREF): New.
>            * include/bits/stl_tree.h: Adapt to use latter.
>            (_Rb_tree<>::_M_clone_node): Add _MoveValue template parameter.
>            (_Rb_tree<>::_M_mbegin): New.
>            (_Rb_tree<>::_M_begin): Use latter.
>            (_Rb_tree<>::_M_copy): Add _MoveValues template parameter.
>            * testsuite/23_containers/map/allocator/move_cons.cc: New test.
>            * testsuite/23_containers/multimap/allocator/move_cons.cc: 
>New test.
>            * testsuite/23_containers/multiset/allocator/move_cons.cc: 
>New test.
>            * testsuite/23_containers/set/allocator/move_cons.cc: New test.
>
>Ok to commit once all tests have complete ?

Yes, OK for trunk, thanks!




      reply	other threads:[~2020-11-20 10:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 20:51 François Dumont
2020-11-17 23:50 ` Jonathan Wakely
2020-11-19  6:46   ` François Dumont
2020-11-19 11:31     ` Jonathan Wakely
2020-11-19 13:20       ` François Dumont
2020-11-20  7:17       ` François Dumont
2020-11-20 10:22         ` 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=20201120102259.GK1312820@redhat.com \
    --to=jwakely@redhat.com \
    --cc=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).