Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-06-27 07:22:42


Markus Werle wrote:
> <posted & mailed>
>
> Markus Werle wrote:
>
>> OK, that's a solution.
>
> No it is not :-(
> still having problems with template functions:

[...]

> template <class T>
> inline
> std::string Foo(const T& t) {}

[...]

> // THIS HERE FAILS TO COMPILE!
> for_each_pair(M.begin(), M.end(),
> l::bind(&Foo<std::string>, l::_2));

This is a language problem. A function template is treated as if it names an
overload set, even when the supplied template arguments limit that set to a
single instance.

Many compilers accept the code above as an extension.

There is an open issue about this problem:

http://std.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#115

Workaround:

std::string (*pf)(std::string const &) = &Foo;

for_each_pair(M.begin(), M.end(), l::bind(pf, l::_2));


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