Search code examples
c++constantspass-by-referencethrust

passing a const reference of a tuple to a functor


I have a functor which needs to modify tuple values. So i am passing a const reference to it.

Here is my code :

void operator() (thrust::tuple<const int&,const float&> tup)
{
    thrust::get<1> (tup) += 10;
    thrust::get<0> (tup) += 10;

}

But I am getting an error : error: expression must be a modifiable lvalue Clearly I am not modifying the reference, I am only modifying the value referenced by the tuple.


Solution

  • ..which needs to modify tuple values. So I am passing a const..

    Do not pass a const and you are going to be fine.