作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好的,代码是:
vector<vector<double>> imageFiltered;
// some processing codes here
parallel_for( blocked_range<unsigned>(0, imageFiltered.size()),
[=](const blocked_range<unsigned>& r) {
for( unsigned i = r.begin(); i != r.end(); ++i ){
for( unsigned j = 0; j != imageFiltered[i].size(); ++j ) {
imageFiltered[i][j] = 0; // error here:expression must be a modifiable lvalue
}
}
});
我已经编写了另一个类似的代码块,它工作得很好。所以,这里有一点帮助。PS:parallel_for 来自 Interl TBB。
最佳答案
[=] 导致 lambda 按值捕获,这意味着它创建 imageFiltered 的副本,并且该副本被标记为“const”。将 [=] 更改为 [&] 以通过引用捕获 imageFiltered,这应该可以消除问题。
关于lambda表达式错误: expression must be a modifiable lvalue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15566023/
我是一名优秀的程序员,十分优秀!