Boost logo

Boost :

From: chr1701_at_[hidden]
Date: 2001-07-22 20:05:00


i try to compile the 'function'-example from the documentation. I use
MSVC++ 6.0, SP 5. I have read that there are some glitches with
MSVC++ and i hope that somebody can help me...

  struct X {
    int foo(int);

  boost::function<int, int> f;
  X x;
  f = std::bind1st(std::mem_fun(&X::foo), &x);

  f(5); // Call

I get the following compilation error:

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 changed "int X::foo(int)" to "int X::foo(void)" and the error
message changes:

error C2039: 'second_argument_type' : is not a member
of 'mem_fun_t<int,struct X>'
   see reference to class template
instantiation 'std::binder1st<class std::mem_fun_t<int,struct X> >'
being compiled

Any idea what i can do to run the example, or is there another way of
assigning a member of X to the 'function'-object? I want to implement
an event queue where every class can register an event handler. It
would be cool if those classes just create a 'function'-object, and
when an event occurs this object is called. From reading the
documentation that should be possible with 'function' and i really
would like to use it, it's just that i can't compile...

Thanks for your help...

Boost list run by bdawes at, gregod at, cpdaniel at, john at