`

boost 信号槽

阅读更多
#include<boost/signals2.hpp>
#include<iostream>
using namespace boost::signals2;
using namespace std;

void slots1()
{
    cout << "slots1 called" << endl;
}

template<int T>
class slots2{
public:
    void operator()()
    {
        cout << "slots2 called," << T << endl;
    }
};

int main()
{
    signal<void()> sig;
    //第一个参数是组号,组号小的先call
    sig.connect(5,&slots1);
    sig.connect(7,slots2<1>());
    sig.connect(5,slots2<10>());
    sig.connect(7,slots2<111>(),at_front);//at_front可以让slots2在第7组最先call
    sig();
}

slots1 called
slots2 called,10
slots2 called,111
slots2 called,1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics