1 // Example program for passing arguments from signal invocations to slots.
2 //
3 // Copyright Douglas Gregor 2001-2004.
4 // Copyright Frank Mori Hess 2009.
5 //
6 // Use, modification and
7 // distribution is subject to the Boost Software License, Version
8 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 // For more information, see http://www.boost.org
11
12 #include <iostream>
13 #include <boost/signals2/signal.hpp>
14
15 //[ slot_arguments_slot_defs_code_snippet
print_args(float x,float y)16 void print_args(float x, float y)
17 {
18 std::cout << "The arguments are " << x << " and " << y << std::endl;
19 }
20
print_sum(float x,float y)21 void print_sum(float x, float y)
22 {
23 std::cout << "The sum is " << x + y << std::endl;
24 }
25
print_product(float x,float y)26 void print_product(float x, float y)
27 {
28 std::cout << "The product is " << x * y << std::endl;
29 }
30
print_difference(float x,float y)31 void print_difference(float x, float y)
32 {
33 std::cout << "The difference is " << x - y << std::endl;
34 }
35
print_quotient(float x,float y)36 void print_quotient(float x, float y)
37 {
38 std::cout << "The quotient is " << x / y << std::endl;
39 }
40 //]
41
main()42 int main()
43 {
44 //[ slot_arguments_main_code_snippet
45 boost::signals2::signal<void (float, float)> sig;
46
47 sig.connect(&print_args);
48 sig.connect(&print_sum);
49 sig.connect(&print_product);
50 sig.connect(&print_difference);
51 sig.connect(&print_quotient);
52
53 sig(5., 3.);
54 //]
55 return 0;
56 }
57
58