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, Marc Glisse wrote:

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.

Or instead of using directly a functor on the values, one could write the algorithm using a functor on iterators, which would take a and b and return either *a<*b or cmp(*a,*b). Maybe not so nice.


--
Marc Glisse


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