Boost version: 1.30.2 Boost Lib: Function OS: Windows XP Pro SP 1 Dev. Env.: Microsoft VS6 SP 6, .NET 2003 Platform SDK Feb 2003, DirectX9 SDK Problem: Can't get an example similar to the one found in the tutorial to work. // ************************************* #include <boost/function.hpp> #include <functional> struct X { int foo(int v) { return v;} }; int main(int argc, char* argv[]) { boost::function1<int, int> f; X x; f = std::bind1st ( std::mem_fun(&X::foo), &x ); f(5); // Call x.foo(5) return 0; } //*************************************** I get this error message: : error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'int (__thiscall X::*)(int)'
On Friday 21 November 2003 05:33 pm, Kim wrote:
Can't get an example similar to the one found in the tutorial to work.
// ************************************* #include <boost/function.hpp> #include <functional>
struct X { int foo(int v) { return v;} };
int main(int argc, char* argv[]) { boost::function1<int, int> f; X x; f = std::bind1st ( std::mem_fun(&X::foo), &x ); f(5); // Call x.foo(5) return 0; }
//***************************************
I get this error message: : error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R
(__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'int (__thiscall X::*)(int)'
I believe this is actually a bug in the standard library that ships with MSVC 6.0. I suggest you use Boost.Bind instead: f = boost::bind(&X::foo, &x, _1); Doug
participants (2)
-
Douglas Gregor
-
Kim