1 // Multiple slot 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_def_code_snippet 15 struct Hello 16 { operator ()Hello17 void operator()() const 18 { 19 std::cout << "Hello"; 20 } 21 }; 22 //] 23 24 //[ world_def_code_snippet 25 struct World 26 { operator ()World27 void operator()() const 28 { 29 std::cout << ", World!" << std::endl; 30 } 31 }; 32 //] 33 main()34int main() 35 { 36 //[ hello_world_multi_code_snippet 37 boost::signals2::signal<void ()> sig; 38 39 sig.connect(Hello()); 40 sig.connect(World()); 41 42 sig(); 43 //] 44 45 return 0; 46 } 47 48