C ++ this(在这种情况下将是当前类的链接)
所以有:
struct A { void foo(int) { } };
typedef std::function<void(int)> Function;
typedef std::vector<Function> FunctionSequence;
typedef FunctionSequence::iterator FunctionIterator;
FunctionSequence funcs;
A a;
funcs.push_back(std::bind(&A::foo, &a, std::placeholders::_1));
funcs.push_back(std::bind(&B::bar, &b, std::placeholders::_1));
// this calls a.foo(42) then b.bar(42):
for (FunctionIterator it(funcs.begin()); it != funcs.end(); ++it)
(*it)(42);
如果我们在课堂上A
订阅funcs.push_back
,我们会说而不是&a
this
没有找到相关结果
已邀请:
2 个回复
孝铜差
总是等于
,如通过
调用的实例方法所见。
亥套惟间连
里面订阅,你想将回调存储到这个特定的
实例。如果是,那么你需要
。 我们不知道您的需求,我可以想象所有三种变体(
,
或
)都是正确的情况。