我想從C#翻譯爲C++過濾函數的圖像,我在互聯網上找到,所以我可以編譯一個DLL,並在我的項目中使用它。 原來的C#代碼:C#lambda函數的意義和C++翻譯
Parallel.For(0, height, depthArrayRowIndex => {
for (int depthArrayColumnIndex = 0; depthArrayColumnIndex < width; depthArrayColumnIndex++) {
var depthIndex = depthArrayColumnIndex + (depthArrayRowIndex * width);
.
.
.
... other stuff ...
}
我的問題的第一部分是:如何
depthArrayRowIndex => {
的作品? 什麼意思有depthArrayRowIndex
在:
var depthIndex = depthArrayColumnIndex + (depthArrayRowIndex * width);
這是我的C++編譯:
concurrency::parallel_for(0, width, [&widthBound, &heightBound, &smoothDepthArray]() {
for (int depthArrayColumnIndex = 0; depthArrayColumnIndex < width; depthArrayColumnIndex++) {
int depthIndex = depthArrayColumnIndex + (depthArrayRowIndex * width);
.
.
.
... other stuff ...
}
但顯然這裏depthArrayRowIndex
已經沒有意義了。 如何翻譯C++中的C#代碼?
謝謝你非常非常多! :-)
這是lambda的一個參數。 –
對不起...我很愚蠢!你能否更好地解釋一下lambda函數的參數是什麼? – Apache81
將某物傳遞給lambda,與參數 –