Ticket #12483: signals.cpp

File signals.cpp, 769 bytes (added by kim.lykke.johansen@…, 6 years ago)
Line 
1#include "boost/signals2.hpp"
2#include <iostream>
3
4
5class SignalTest : public boost::signals2::trackable
6{
7public:
8 SignalTest() {};
9
10 void printInfo(const std::string name, int num)
11 {
12 std::cout << "Signal: " << name << " " << num << std::endl;
13 }
14};
15
16
17
18
19int main()
20{
21 boost::signals2::signal<void (const std::string&, int)> sig;
22
23 SignalTest test1;
24 // sig.connect(boost::bind(&SignalTest::printInfo, test1, _1, _2));
25 sig.connect(boost::bind(&SignalTest::printInfo, &test1, _1, _2));
26 sig("Test", 1);
27
28 {
29 SignalTest test2;
30 // sig.connect(boost::bind(&SignalTest::printInfo, test2, _1, _2));
31 sig.connect(boost::bind(&SignalTest::printInfo, &test2, _1, _2));
32 sig("Test", 2);
33 }
34
35 return 0;
36}