(Note [this question](https://stackoverflow.com/questions/33156534/pass-cuda-array-to-thrustinclusive-scan) absolutely does not answer my question.)

I would like to use `thrust::transform_reduce` to change the values of an array as well as perform a reduction. However, `transform_reduce` seems require that transform/reduce functions have pass-by-value semantics. Is there any way to access the values by address?

The following MWE exemplifies the issue:

```cpp
#include <thrust/scan.h>

#include <iostream>

int main(){
  const int N = 10;

  //Yes, I wish to use raw pointers rather than nice device vectors.
  int* data;
  if(cudaMalloc(&data, N * sizeof(int))!=cudaSuccess){
    std::cout<<"Couldn't allocate!"<<std::endl;
    return -1;
  }

  const int answer = thrust::transform_reduce(
    data, data + N,
    [](auto x) -> int32_t {
      //I would like to change the values of data here
      return 2;
    },
    int32_t{0},
    [](const int32_t running_sum, const int32_t this_value) -> int32_t {
      return running_sum + this_value;
    }
  );

  if(answer!=20){
    std::cout<<"Wrong answer!"<<std::endl;
    return -1;
  }

  cudaFree(data); //In actuality, I'd do something with transformed data here

  return 0;
}

```