This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Use C++11 direct init in __debug::forward_list
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 15 Oct 2018 10:58:51 +0100
- Subject: Re: Use C++11 direct init in __debug::forward_list
- References: <a7545824-cd01-622e-a328-8abcda996fc3@gmail.com>
On 11/10/18 22:46 +0200, François Dumont wrote:
This patch makes extensive use of C++11 direct init in
__debug::forward_list.
Doing so I also try to detect useless creation of safe iterators in
debug implementation. In __debug::forward_list there are severals but
I wonder if it is worth fixing those. Most of them are like this:
void
splice_after(const_iterator __pos, forward_list& __list)
{ splice_after(__pos, std::move(__list)); }
__pos is copied.
Do you think I shouldn't care, gcc will optimize it ?
I think the _Safe_iterator construction/destruction is too complex to
be optimised away (it locks a mutex, doesn't it?).
Normally I'd say you could use std::move(__pos) but IIRC that's even
more expensive than a copy, as it locks two mutexes.
I wonder if it would be ok in debug implementation to use this kind of
signature:
void splice_after(const const_iterator& __pos, forward_list& __list)
Iterator taken as rvalue reference ?
I guess it is not Standard conformant so not correct but maybe I could
add a private _M_splice_after with this signature.
It doesn't seem worthwhile to me.