FWIW,我的投票将是任何一天的Boost Signals.
Boost确保可移植性.当然它与Boost Asio,Functional,Bind等很好地集成.
更新:
Signals2
本文档描述了原始Boost.Signals库的线程安全变体.对支持线程安全的接口进行了一些更改,主要是关于自动连接管理.[....]
Boost确保可移植性.当然它与Boost Asio,Functional,Bind等很好地集成.
boost :: signals2 :: signal sig;
sig.connect(&print_sum);
sig.connect(&print_product);
sig.connect(&print_difference);
sig.connect(&print_quotient);
sig(5., 3.);
Run Code Online (Sandbox Code Playgroud)
该程序将打印出以下内容:
The sum is 8
The product is 15
The difference is 2
The quotient is 1.66667
Run Code Online (Sandbox Code Playgroud)
样本行动:
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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
603 次 |
| 最近记录: |