Steven Watanabe wrote:
But you understand why I'd like the templated version to work. I have other predicates to test
Ok. The compiler can't deduce T in
template <class T> function
neg(function func); unless the argument is already a boost::function. No implicit conversions allowed.
I suspected it was too much to ask for. But I didn't know any alternative.
template<class F> struct not_t { typedef bool result_type; template<class T> bool operator()(const T& t) { return(!f(t)); } F f; };
template<class F> not_t<F> neg(F f) { not_t<F> result = { f }; return(result); }
This works as expected! So it's a function object, huh. I haven't used those before. I changed your solution in two small ways: * I removed the unused typedef. * I added some overloads of operator() to handle multiple parameters. This is a useful feature to have. Thanks for your help! -- Michiel Helvensteijn