Topic: std::less<T,F> ?
Author: djp1@doc.ic.ac.uk (David Pearce)
Date: Fri, 9 May 2003 17:20:38 +0000 (UTC) Raw View
Hello,
I'm not sure if this has already been suggested or not. However, it
seems to me that extending std::less in the following manner would be
useful:
> template<class T, class F = identity<T> >
> class less {
> private:
> F _s;
> public:
> bool operator()(T const &a, T const &b) const {
> return _s(a) < _s(b);
> }
> };
The reason behind this is that it allows things like:
> typedef pair<int,int> p_t;
> typedef set<p_t,less<p_t,select2nd<p_t> > > nset_t;
Clearly, this also applies to other functors such as greater.
Does anyone agree/disagree ?
Cheers,
David Pearce
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]