Boost logo

Boost Users :

Subject: [Boost-users] [signals2, bind] connecting a slot with unrelated signature
From: Igor R (boost.lists_at_[hidden])
Date: 2009-08-06 12:07:26


Hello,

Lets assume we've got an arbitrary signal that we don't know it's
exact signature, and a function we'd like to connect as a slot. The
function ignores all the signal arguments:

void callback()
{
  std::cout << "kuku" << std::endl;
}

int main()
{
  signals2::signal<void(int, double, int)> sig;
  sig.connect(boost::bind(callback));
  sig();
}

The above compiles and works.
Now I'd like not just to ignore signal's args, but to pass my own param:

void callback(int cookie)
{
  std::cout << cookie << std::endl;
}

int main()
{
  signals2::signal<void(int, double, int)> sig;
  // I'd like to bind cookie=5 and to connect such a binder to the signal.
  // Is this possible without defining "manual" functors?
  sig.connect(???);
  sig();
}


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