Boost logo

Boost Users :

From: Andriy Tylychko \(mail.ru\) (telya_at_[hidden])
Date: 2006-08-29 14:19:45


> 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<double(double)> pFunc = boost::bind<double,
double(&)(double, double)>(std::pow, _1, -3);

In this example placeholder's presence doesn't matter. Simplified version
w/o placeholder:

boost::function<double(void)> pFunc = boost::bind<double, double(&)(double,
double)>(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<double(&)(double,
double)>(std::pow);" or other overloads

HTH,
Andriy Tylychko,
telia_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net