2016-11-23 49 views
0

我需要編譯一個嵌入Posix中的bind函數,並且不能使用boost::bindstd::bind如何拆分函數: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)
和功能減低:
void IndexThread::reduce(boost::function<void(int,int,RunningStats*)> callPerIndex, int first, int end, int stepSize = 0)

PLZ,幫我分的功能,我不擅長C++

+2

爲什麼你不能使用'boost :: bind'(或者'std :: bind')?特別是如果你(顯然)仍然可以繼續使用'boost :: function'? –

+0

這是我以前的代碼,我需要全部更改。功能減少,點擊「跟隨符號」,並顯示功能。 – nistar

+0

我的POSIX嵌入式不能使用庫'增強' – nistar

回答

0

如果你不能使用boost或C++ 11 ..在這種情況下,喲U可以嘗試這樣的:

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