0

I currently have something like this

void asomeMethod(int q)
{
    std::cout << "Method with parameter " << q ;
}

int main()
{
     boost::function<void(int)> parfunct;
     parfunct = boost::bind(&asomeMethod,12);
     parfunct;  //Does not call asomeMethod ??
    return 0;
}

I want to call the function ptr but the method is not being called ? Any suggestions on what I might be doing wrong ?

Rajeshwar
  • 11,179
  • 26
  • 86
  • 158

1 Answers1

1

It has to be boost::function<void()>, since there's no remaining argument.

Then call it like a function:

parfunct();
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
  • in that case I get Error `error C2064: term does not evaluate to a function taking 0 arguments` – Rajeshwar Oct 25 '13 at 18:53
  • @Rajeshwar: Sorry, fixed. Extraneous arguments in `bind` are ignored, subtle error... The `function` type needs to be what you *call*, not the input of `bind`. – Kerrek SB Oct 25 '13 at 18:54