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: Implementing normal algorithms using predicate versions


On Nov 28, 2004, at 7:00 AM, caj wrote:

Hi!

I apologise, as I'm sure this question has a simple answer, but I can't find it...

Many algorithms have a predicated version, and a version which simply uses operator<. Why not implement the operator< versions using the predicated versions? This would seem to half the size of the algorithm heaader, remove lots of redundant code, and on -O2 seems to produce identical code...

It's a good idea, but we can't quite plug std::less into the predicate version of the algorithms. There are a few corner cases where that would do something different in a way the user could detect. I think what we could and should do is write our own predicates that are guaranteed to behave the same way as the version using bare operator<.


--Matt


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