This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Remove algo code duplication
- From: Marc Glisse <marc dot glisse at inria dot fr>
- 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>
- Date: Fri, 4 May 2012 21:49:13 +0200 (CEST)
- Subject: Re: Remove algo code duplication
- References: <4F9BA3CF.2000606@gmail.com> <alpine.DEB.2.02.1204281307410.2528@laptop-mg.saclay.inria.fr> <4FA18C34.7070004@gmail.com> <alpine.DEB.2.02.1205022144370.2504@laptop-mg.saclay.inria.fr> <4FA42D26.6060004@gmail.com>
- Reply-to: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
On Fri, 4 May 2012, François Dumont wrote:
I though that I wouldn't have to take care of this kind of use case but you
are right I better handle it correctly.
So I am going to write tests challenging the number of constructors invoked
when algos are used with or without my patch, in C++98 and C++11 modes.
To be continued...
To be clear: I don't think it is possible to remove the operator< special
case and replace it with a forwarding functor (like you wrote, or like
Jonathan's) without some detectable difference. The only chance I can see
would be to somehow get the right &operator< (how do you ask the compiler
to perform overload resolution, but then not apply the function, just give
you a pointer?) and pass that bare function pointer to the algorithm.
However, just because it changes things a little bit doesn't mean using a
forwarding functor shouldn't be done...
(by the way, as a core feature, it would be nice if default arguments
could participate in template deduction, so we could write the algorithms
with a single declaration, with the functor that defaults to our operator<
wrapper)
--
Marc Glisse