title: Finding the maximum element value AND its position using CUDA Thrust
body: <p>How do I get not only the value but also the position of the maximum (minimum) element (<code>res.val</code> and <code>res.pos</code>)?</p>
  
  <pre><code>thrust::host_vector&lt;float&gt; h_vec(100);
  thrust::generate(h_vec.begin(), h_vec.end(), rand);
  thrust::device_vector&lt;float&gt; d_vec = h_vec;
  
  T res = -1;
  res = thrust::reduce(d_vec.begin(), d_vec.end(), res, thrust::maximum&lt;T&gt;());
  </code></pre>