我有一个 functor
需要修改元组值。所以我将 const reference
传递给它。
这是我的代码:
void operator() (thrust::tuple<const int&,const float&> tup)
{
thrust::get<1> (tup) += 10;
thrust::get<0> (tup) += 10;
}
但是我得到一个错误:
错误:表达式必须是可修改的左值
显然我没有修改引用,我只是修改元组引用的值。
最佳答案
..which needs to modify tuple values. So I am passing a const..
不要传递 const,你会没事的。
关于c++ - 将元组的 const 引用传递给仿函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36843441/