我需要在嵌入式Posix中编译bind函数,并且不能使用boost::bind或std::bind。
所以我想拆分函数:threadReducer.reduce(boost::bind(&DepthMap::observeDepthRow, this, _1, _2, _3), 3, height-3, 10);
其中函数observeDepthRow:
void DepthMap::observeDepthRow(int yMin, int yMax, RunningStats* stats)
和函数reduce:
void IndexThread::reduce(boost::function<void(int,int,RunningStats*)> callPerIndex, int first, int end, int stepSize = 0)
请帮我拆分函数,我不擅长C++
发布于 2016-11-24 10:00:37
如果您不能使用boost或c++11 ..在这种情况下,您可以像这样尝试:
void IndexThread::reduce(void(*function)(int,int,RunningStats*), int first, int end, int stepSize = 0)让你的observeDepthRow static
static void DepthMap::observeDepthRow(int yMin, int yMax, RunningStats* stats)然后你可以这样叫它:
threadReducer.reduce(observeDepthRow, 3, height-3, 10);虽然在这种情况下,您必须将方法设置为static,但如果您不希望这样做,请查看this。
https://stackoverflow.com/questions/40764988
复制相似问题