Sebastian Weber
Hello everybody!
I ran into a very weird problem with boost::bind and
boost::function. I am using boost 1.33.1 with a g++ 4.0.3 on
a Ubuntu dapper system. The code which does not compile is:
boost::function< double(double) > pFunc =
boost::bind(std::pow, _1, -3);
...
You have to specify which overloaded version of std::pow() you'd like to
use:
boost::function pFunc = boost::bind(std::pow, _1, -3);
In this example placeholder's presence doesn't matter. Simplified version
w/o placeholder:
boost::function pFunc = boost::bind(std::pow, 0.0, 0.0);
requires explicit template parameter too, regardless of the fact that both
arguments can be deduced as doubles and so, only one overloaded version is
the best match. This can be illustrated by simpler example:
template <typename F> void foo(F f) {}
foo(std::pow); // ERROR, should be "foo(std::pow);" or other overloads
HTH,
Andriy Tylychko,
telia@vichnavich.com