AMDG Michiel Helvensteijn wrote:
Ok, the subject-line might be a bit confusing. :-)
I have the following template function:
template<class T> bool is(const string& str);
Its implementation is not important. It checks if a string can be converted to type T by std::stringstream. I also have the following function:
template <class T> function
neg(function func) { return !bind(func, _1); } Which I use in the following way:
BOOST_CHECK_PREDICATE( neg(is<int>), ("text") );
But the compiler (GCC 4.1.2) complains:
error: no matching function for call to 'neg(<unresolved overloaded function type>)'
What's the problem. And, also, what's the solution? :-)
Internal to the compiler, the type of is<int> is a special type used to
flag overloads. (unresolved overloaded function type). The problem is
that you are passing this special type to a function template (the
boost::function constructor) which does not provide enough information
to resolve the overloading. The solution is to add a cast:
static_cast