This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Remove algo code duplication


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]