Topic: Relaxed unary_negate (was std::copy_if - most likely canidate?)
Author: abarbati@iaanus.com (Alberto Barbati)
Date: Thu, 13 Feb 2003 03:20:08 +0000 (UTC) Raw View
Dietmar Kuehl wrote:
> template <typename Predicate>
> struct unary_negate {
> unary_negate(Predicate predicate): m_predicate(predicate) {}
> template <typename T>
> bool operator()(T const& object) const { return !m_predicate(object); }
> Predicate m_predicate;
> };
That's nice! Using SFINAE we could write an improved version of
std::not1 that behaves like this:
1) if the predicate is adaptable the implementation is identical to the
old one and returns an adaptable predicate;
2) if the predicate is not adaptable, we use the alternative
implementation and return a non-adaptable predicate.
What do you think? I'm pretty sure someone has already proposed it, but
sounds to me a nice little addition to the standard.
Of course we could do the same for std::not2.
Alberto
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
---
[ 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 ]