我正在尝试使用std::bind
绑定this
到中使用的方法QtConcurrent::blockingMapped
标题:
class TuringMachine
{
private:
TRTable table;
std::set<ConfigNode*> currentConfigs;
//function object
std::function<std::set<ConfigNode*>( const TuringMachine*, ConfigNode*)> step_f;
//method it will hold
std::set<ConfigNode *> step(TuringMachine* this_m ,ConfigNode *parent);
std::set<ConfigNode*>& makeStep();
}
资源:
TuringMachine::TuringMachine(/**/)
{
step_f = std::bind(&TuringMachine::step, this, std::placeholders::_1);
}
std::set<ConfigNode*> &TuringMachine::makeStep(){
auto configSet = QtConcurrent::blockingMapped<QLinkedList<std::set<ConfigNode*>>>(currentConfigs, step_f);//concurrent execution!
/**/
return currentConfigs;
}
std::set<ConfigNode*> TuringMachine::step(TuringMachine *this_m, ConfigNode * parent){ //the actual step
/**/
}
blockingMapped
所以我在这里做的是在每个ConfigNode
in上同时运行 step currentConfigs
。我使用std::bind
绑定this
到,step
所以它只需要一个参数,如blockingMapped
.
我越来越
error: no match for call to '(std::_Bind<std::_Mem_fn<std::set<ConfigNode*> (TuringMachine::*)(TuringMachine*, ConfigNode*)>(TuringMachine*, std::_Placeholder<1>)>) (const TuringMachine*, ConfigNode*)'
.../Qt/474/gcc/include/QtCore/qtconcurrentmapkernel.h:121: error: no match for call to '(std::function<std::set<ConfigNode*>(const TuringMachine*, ConfigNode*)>) (ConfigNode* const&)'
.../Qt/474/gcc/include/QtCore/qtconcurrentmapkernel.h:136: error: no match for call to '(std::function<std::set<ConfigNode*>(const TuringMachine*, ConfigNode*)>) (ConfigNode* const&)'
和note: 2 arguments expected, 1 provided
我哪里做错了?
编辑
更正的工作版本(供将来“参考”):
标题:
//function object
std::function<std::set<ConfigNode*>( ConfigNode*)> step_f;
//method it will hold
std::set<ConfigNode *> step(ConfigNode *parent);
资源:
TuringMachine::TuringMachine(/**/)
{
step_f = std::bind(&TuringMachine::step, this, std::placeholders::_1);
}