Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/signals/example/no_function.cpp @ 20

Last change on this file since 20 was 12, checked in by landauf, 18 years ago

added boost

File size: 1.0 KB
Line 
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#include <string>
13#include <functional>
14
15void print_sum(int x, int y)
16{
17  std::cout << "Sum = " << x+y << std::endl;
18}
19
20void print_product(int x, int y)
21{
22  std::cout << "Product = " << x*y << std::endl;
23}
24
25void print_quotient(float x, float y)
26{
27  std::cout << "Quotient = " << x/y << std::endl;
28}
29
30int main()
31{
32  typedef boost::signal2<void, int, int, boost::last_value<void>,
33                         std::string, std::less<std::string>,
34                         void (*)(int, int)> sig_type;
35
36  sig_type sig;
37  sig.connect(&print_sum);
38  sig.connect(&print_product);
39
40  sig(3, 5); // print sum and product of 3 and 5
41
42  // should fail
43  //   sig.connect(&print_quotient);
44}
Note: See TracBrowser for help on using the repository browser.