现在的位置: 首页 > 综合 > 正文

CC_CALLBACK_#

2014年01月02日 ⁄ 综合 ⁄ 共 799字 ⁄ 字号 评论关闭

// new callbacks based on C++11
#define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__)
#define CC_CALLBACK_1(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, ##__VA_ARGS__)
#define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__)

#include <iostream>
#include <functional>
using namespace std;

#define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2)
#define COUT(...) cout<<"1111"##__VA_ARGS__
class plane
{
public:
void fun(int a, int b)
{
cout<<"fun"<<endl;
}
void func()
{
std::function<void(int, int)>p = CC_CALLBACK_2(plane::fun, this);
p(1,2);

}
};

int main()
{
plane *p = new plane;

p->func();

COUT("222");
}

抱歉!评论已关闭.