• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Beginner hello world example for Boost.Signals2
2 // Copyright Douglas Gregor 2001-2004.
3 // Copyright Frank Mori Hess 2009.
4 //
5 // Use, modification and
6 // distribution is subject to the Boost Software License, Version
7 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
10 
11 #include <iostream>
12 #include <boost/signals2/signal.hpp>
13 
14 //[ hello_world_def_code_snippet
15 struct HelloWorld
16 {
operator ()HelloWorld17   void operator()() const
18   {
19     std::cout << "Hello, World!" << std::endl;
20   }
21 };
22 //]
23 
main()24 int main()
25 {
26 //[ hello_world_single_code_snippet
27   // Signal with no arguments and a void return value
28   boost::signals2::signal<void ()> sig;
29 
30   // Connect a HelloWorld slot
31   HelloWorld hello;
32   sig.connect(hello);
33 
34   // Call all of the slots
35   sig();
36 //]
37 
38   return 0;
39 }
40 
41