1

How would I combine two signals of the same type?

Let's say I have two signals with one connection each, foo and bar.

boost::signals2::signal<void ()> foo;
foo.connect([]{
  std::cout << "Hello from foo!" << std::endl;
});

boost::signals2::signal<void ()> bar;
bar.connect([]{
  std::cout << "Hello from bar!" << std::endl;
});

How would I combine the two already created signals later so that foo contains both slots?

I can use anything from boost and C++14 or later.

  • 1
    Do you really need to declare the second signal? Cant you just attach 2 slots to foo? – const_ref Feb 26 '20 at 22:12
  • The example above is an over simplification of my actual problem. I've got many many signals all over a complex control system, and if I could combine signals after they were initialized it would be convenient. – Matthew Nichols Feb 27 '20 at 18:18
  • As `signal`s are callable objects, shouldn't `foo.connect(bar);` just work? – beerboy Mar 01 '20 at 21:09

0 Answers0