diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/boost/libs/signals2/example/slot_arguments.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream/18.2.2.tar.xz ceph-upstream/18.2.2.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/signals2/example/slot_arguments.cpp')
-rw-r--r-- | src/boost/libs/signals2/example/slot_arguments.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/boost/libs/signals2/example/slot_arguments.cpp b/src/boost/libs/signals2/example/slot_arguments.cpp new file mode 100644 index 000000000..86c49cb6f --- /dev/null +++ b/src/boost/libs/signals2/example/slot_arguments.cpp @@ -0,0 +1,57 @@ +// Example program for passing arguments from signal invocations to slots. +// +// Copyright Douglas Gregor 2001-2004. +// Copyright Frank Mori Hess 2009. +// +// Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// For more information, see http://www.boost.org + +#include <iostream> +#include <boost/signals2/signal.hpp> + +//[ slot_arguments_slot_defs_code_snippet +void print_args(float x, float y) +{ + std::cout << "The arguments are " << x << " and " << y << std::endl; +} + +void print_sum(float x, float y) +{ + std::cout << "The sum is " << x + y << std::endl; +} + +void print_product(float x, float y) +{ + std::cout << "The product is " << x * y << std::endl; +} + +void print_difference(float x, float y) +{ + std::cout << "The difference is " << x - y << std::endl; +} + +void print_quotient(float x, float y) +{ + std::cout << "The quotient is " << x / y << std::endl; +} +//] + +int main() +{ +//[ slot_arguments_main_code_snippet + boost::signals2::signal<void (float, float)> sig; + + sig.connect(&print_args); + sig.connect(&print_sum); + sig.connect(&print_product); + sig.connect(&print_difference); + sig.connect(&print_quotient); + + sig(5., 3.); +//] + return 0; +} + |