vendredi 27 novembre 2015

Fixing a parameter when using std::bind

This code doesn't compile, I don't get why:

struct C { int a;};

void foo(C c, int s)
{
  cout << c.a << s;
}

int main()
{
  std::function<void(C,int)> call = std::bind(&foo,std::placeholders::_1,5);
  C c;
  c.a = 5;
  call(c);
  return 0;
}

I get:

No match for call to std::function<void(C,int)> (C&)

Aucun commentaire:

Enregistrer un commentaire