VC 7.1: unable to bind specialized member function template

Hi all, this code sample produces a compiler error on VC 7.1. It seems that boost::bind isn't able to get the right type for the specialization of the member function template [&Test::g<Type1, Type2>]. Is there a good workaround? (The only one I could find so far is to 'hide' the function template as normal member function in a class template.) Intel 8.0 compiles ok! #include <boost/bind.hpp> #include <boost/function.hpp> class Test { public: template <typename Type1, typename Type2> void f(Type1 one, Type2 two) { boost::function<void (Type1, Type2)> bf = boost::bind(&Test::g<Type1, Type2>, this, one, two); } template <typename Type1, typename Type2> void g(Type1, Type2) { } }; int main() { Test t; t.f(0, 0); }

Stefan Slapeta wrote:
Hi all,
this code sample produces a compiler error on VC 7.1. It seems that boost::bind isn't able to get the right type for the specialization of the member function template [&Test::g<Type1, Type2>].
Is there a good workaround? (The only one I could find so far is to 'hide' the function template as normal member function in a class template.)
Use void (Test::*pmf) (Type1, Type2) = &Test::g; boost::function<void (Type1, Type2)> bf = boost::bind(pmf, this, one, two);

Peter Dimov wrote:
Use
void (Test::*pmf) (Type1, Type2) = &Test::g;
boost::function<void (Type1, Type2)> bf = boost::bind(pmf, this, one, two);
Thanks! Do you know a short example which isolates the problem? (There seems to be a confusion with bind for pointer to data member.) I just would like to ensure that this is fixed in VC 8.0. If not, now would be a good time to submit a DR. Stefan
participants (2)
-
Peter Dimov
-
Stefan Slapeta