本文整理汇总了C++中Sender::subscribe方法的典型用法代码示例。如果您正苦于以下问题:C++ Sender::subscribe方法的具体用法?C++ Sender::subscribe怎么用?C++ Sender::subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sender
的用法示例。
在下文中一共展示了Sender::subscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_func
static void test_func(void) {
test_caseStart("Testing functions");
{
Sender<int> s;
tuple<int> x(2);
s.subscribe(func_recv(test_func0));
s.subscribe(bind1_func_recv(2,test_func1));
s.subscribe(bind1_func_recv(x,test_func2));
s.subscribe(bind1_func_recv(const_cast<const tuple<int>&>(x),test_func3));
s.send(1);
for(size_t i = 0; i <= 3; ++i)
test_assertSize(calls[i],1);
}
{
Sender<int&> s;
tuple<int> x(2);
s.subscribe(func_recv(test_func4));
s.subscribe(bind1_func_recv(x,test_func5));
int y = 1;
s.send(y);
for(size_t i = 4; i <= 5; ++i)
test_assertSize(calls[i],1);
}
test_caseSucceeded();
}
示例2: test_memfunc
static void test_memfunc(void) {
test_caseStart("Testing member functions");
{
Test test;
const Test ctest;
Sender<int> s;
tuple<int> x(2);
s.subscribe(mem_recv(&test,&Test::test_func6));
s.subscribe(bind1_mem_recv(2,&test,&Test::test_func7));
s.subscribe(bind1_mem_recv(x,&test,&Test::test_func8));
s.subscribe(bind1_mem_recv(const_cast<const tuple<int>&>(x),&test,&Test::test_func9));
s.subscribe(bind1_mem_recv(x,&ctest,&Test::test_func10));
s.subscribe(bind1_mem_recv(const_cast<const tuple<int>&>(x),&ctest,&Test::test_func11));
s.send(1);
for(size_t i = 6; i <= 11; ++i)
test_assertSize(calls[i],1);
}
{
Test test;
const Test ctest;
Sender<int&> s;
tuple<int> x(2);
s.subscribe(mem_recv(&test,&Test::test_func12));
s.subscribe(bind1_mem_recv(x,&test,&Test::test_func13));
s.subscribe(bind1_mem_recv(x,&ctest,&Test::test_func14));
int y = 1;
s.send(y);
for(size_t i = 12; i <= 14; ++i)
test_assertSize(calls[i],1);
}
test_caseSucceeded();
}