3 回答

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
std::function
<void(void)>
std::function<void(void)> f = std::bind(&Foo::doSomething, this);
using namespace std::placeholders;std::function<void(int,int)> f = std::bind(&Foo::doSomethingArgs, this, _1, _2);
std::function<void(int,int)> f = [=](int a, int b) { this->doSomethingArgs(a, b);}

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊
std::function<void(Foo*)> f = &Foo::doSomething;
this
std::function<void(void)> f = std::bind(&Foo::doSomething, this);

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊
class MyClass{public: void MemberFunc(int value) { //do something }};// Store member function bindingauto callable = std::mem_fn(&MyClass::MemberFunc); // Call with late supplied 'this'MyClass myInst;callable(&myInst, 123);
std::_Mem_fn_wrap<void,void (__cdecl TestA::*)(int),TestA,int> callable
std::function<void(int)> binding = std::bind(callable, &testA, std::placeholders::_1);binding(123); // Call
- 3 回答
- 0 關(guān)注
- 386 瀏覽
添加回答
舉報(bào)