]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/signals/example/print_sum_product.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / signals / example / print_sum_product.cpp
1 // Boost.Signals library
2
3 // Copyright Douglas Gregor 2001-2003. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7
8 // For more information, see http://www.boost.org
9
10 #include <iostream>
11 #include <boost/signals/signal2.hpp>
12
13 struct print_sum {
14 void operator()(int x, int y) const { std::cout << x+y << std::endl; }
15 };
16
17 struct print_product {
18 void operator()(int x, int y) const { std::cout << x*y << std::endl; }
19 };
20
21
22 int main()
23 {
24 boost::signal2<void, int, int> sig;
25
26 sig.connect(print_sum());
27 sig.connect(print_product());
28
29 sig(3, 5); // prints 8 and 15
30
31 return 0;
32 }