
7 Jul
2008
7 Jul
'08
5:32 p.m.
AMDG James Sutherland wrote:
This gives an error: invalid static_cast from type β<unknown type>β to type βint (X::*)(int)β Any other ideas?
What compiler are you using? The following compiles for me with msvc 9.0, gcc 3.4.4 and gcc 4.3.0 #include <boost/function.hpp> #include <boost/bind.hpp> #include <functional> #include <iostream> struct X { int foo(int i) { return ++i; } template<class T> void foo( T& t ); }; int main() { boost::function<int(int)> f; X x; f = boost::bind(static_cast<int(X::*)(int)>(&X::foo), &x, _1); std::cout << f(5) << std::endl; } In Christ, Steven Watanabe