📄 print_sum_product.cpp
字号:
// FD.Delegate library examples
// Copyright Douglas Gregor 2001-2003. 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
// Copyright (C) 2007 JaeWook Choi
// , modified from Boost.Signals print_sum_product.cpp
#include <iostream>
#include <boost/signals/signal2.hpp>
#include <fd/delegate/delegate2.hpp>
struct print_sum {
void operator()(int x, int y) const { std::cout << x+y << std::endl; }
};
struct print_product {
void operator()(int x, int y) const { std::cout << x*y << std::endl; }
};
int main()
{
boost::signal2<void, int, int> sig;
sig.connect(print_sum());
sig.connect(print_product());
sig(3, 5); // prints 8 and 15
fd::delegate2<void, int, int> dg;
dg += print_sum();
dg.add( print_product());
dg(3, 5); // prints 8 and 15
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -