This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Implementing normal algorithms using predicate versions
- From: Matt Austern <austern at apple dot com>
- To: caj <caj at cs dot york dot ac dot uk>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 29 Nov 2004 10:01:21 -0800
- Subject: Re: Implementing normal algorithms using predicate versions
- References: <41A9E80F.6050901@cs.york.ac.uk>
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