Boost logo

Boost Users :

From: Kim (hskim_at_[hidden])
Date: 2003-11-21 17:33:48


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)'


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