title: return pointer rather than vector::iterator and convert vector::iterator to pointer
body: <p>i have a function that its return type is "vector::iterator" in below:</p>
  
  <pre><code>vector&lt;unsigned int&gt;::iterator foo(unsigned int arg, vector&lt;unsigned int&gt; arr, vector&lt;unsigned int&gt; M)
  {    if (arg == 0)
          return arr.begin();
      else if (arg == 2)
          return arr.begin() + arr[arg - 1];
      else
          return arr.begin();
  }
  </code></pre>
  
  <p>the question is this, how to convert its return value to a pointer rather than of std::vector iterator?</p>
  
  <p>i should be convert it for use to kernel in CUDA because we couldn't use vector or its iterator in CUDA</p>
  
  <p>This is my way:</p>
  
  <pre><code>__host__ __device__ unsigned int* foo(unsigned int arg, unsigned int* arr, unsigned int* M)
  {  
      unsigned int* res, tmp;
      if (arg == 0)
          tmp = arr[0];
      else if (arg == 2)
          tmp = arr[0] + arr[arg - 1];
      else
          tmp = arr[0];
          res = &amp;tmp;
      return res; 
  }
  </code></pre>
  
  <p>for work in kernel, for example:</p>
  
  <pre><code>__global__ kernel void kernel . . .
  .
  .
  unsigned int* d_h = foo( , ,)
  .
  .
  </code></pre>
  
  <p>but it's wrong and doesn't work, how to could i do it? Thanks,</p>