title: cuda Thrust how to get the values associated to key
body: <p>I got a list of values/keys in one side and in the other side i got a list of keys.</p>
  <p>I want to get the values associated at this list of keys in a list.</p>
  <p>here my pseudocode</p>
  <p>I don't know how to make my predicate and by the way if it's the good way to reach my goal.</p>
  <pre><code>void pseudoCode()
  {
      const int N = 7;
      thrust::device_vector&lt;vec3&gt; keys1(N);
  
      values[0] = vec3(1.01,1.01,1.0156); 
      values[1] = vec3(1.01,1.01,1.01561);
      values[2] = vec3(1.02,1.52,1.02); 
      values[3] = vec3(1.02,1.52,1.02); 
      values[4] = vec3(1.0,1.0,1.0); 
      values[5] = vec3(5.0,1.0,1.0); 
      values[6] = vec3(5.0,1.5,1.0); 
    
      thrust::device_vector&lt;long&gt; values(N);
      keys1[0] = 0; 
      keys1[1] = 1;
      keys1[2] = 2;
      keys1[3] = 5;
      keys1[4] = 9;
      keys1[5] = 19;
      keys1[6] = 22;
  
      thrust::device_vector&lt;long&gt; to_find(6);
      to_find[0] = 1; 
      to_find[1] = 5;
      to_find[2] = 9;
      
      thrust::device_vector&lt;vec3&gt; output(6);
  
      auto begin = thrust::make_zip_iterator(thrust::make_tuple(keys1.begin(), values.begin()));
      auto end = thrust::make_zip_iterator(thrust::make_tuple(keys1.end(), values.end()));
  
  
      thrust::copy_if(begin, end, output, pred(to_find));
  
      // result 
  
      output[0]=values[1];
      output[1]=values[3];
      output[2]=values[4];
      
  
  }
  </code></pre>
  <p>I try to make my predicate here is my code</p>
  <pre><code>struct FindValue
  {
      thrust::device_vector&lt;long&gt;  ToFind;
      explicit FindValue(thrust::device_vector&lt;long&gt; toFind) : ToFind{toFind} {}
  
      __host__ __device__
      bool operator()(thrust::tuple&lt;vec3, long&gt; x)
      {
          long v = thrust::get&lt;1&gt;(x);
          size_t N = ToFind.size(); 
          for (size_t index=0; index&lt;N; index++)
          {
              if (v==ToFind[index]) return true;
          }   
          return false;
      }
  };
  </code></pre>
  <p>and change the call of copy_if</p>
  <pre><code>thrust::copy_if(begin, end, output, FindValue(to_find));
  </code></pre>
  <p>but i got the errors</p>
  <pre><code>/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy_if.inl(75): error: class &quot;thrust::iterator_system&lt;thrust::device_vector&lt;vec3, thrust::device_allocator&lt;vec3&gt;&gt;&gt;&quot; has no member &quot;type&quot;
            detected during instantiation of &quot;OutputIterator thrust::copy_if(InputIterator, InputIterator, OutputIterator, Predicate) [with InputIterator=thrust::zip_iterator&lt;thrust::tuple&lt;thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;vec3&gt;&gt;, thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;long&gt;&gt;, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type&gt;&gt;, OutputIterator=thrust::device_vector&lt;vec3, thrust::device_allocator&lt;vec3&gt;&gt;, Predicate=FindValue]&quot; 
  cpp_addin_new2.cu(768): here
  
  /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy_if.inl(80): error: no instance of overloaded function &quot;select_system&quot; matches the argument list
              argument types are: (System1, System2)
            detected during instantiation of &quot;OutputIterator thrust::copy_if(InputIterator, InputIterator, OutputIterator, Predicate) [with InputIterator=thrust::zip_iterator&lt;thrust::tuple&lt;thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;vec3&gt;&gt;, thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;long&gt;&gt;, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type&gt;&gt;, OutputIterator=thrust::device_vector&lt;vec3, thrust::device_allocator&lt;vec3&gt;&gt;, Predicate=FindValue]&quot; 
  cpp_addin_new2.cu(768): here
  
  /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy_if.inl(80): error: no instance of overloaded function &quot;thrust::copy_if&quot; matches the argument list
              argument types are: (&lt;error-type&gt;, thrust::zip_iterator&lt;thrust::tuple&lt;thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;vec3&gt;&gt;, thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;long&gt;&gt;, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type&gt;&gt;, thrust::zip_iterator&lt;thrust::tuple&lt;thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;vec3&gt;&gt;, thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;long&gt;&gt;, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type&gt;&gt;, thrust::device_vector&lt;vec3, thrust::device_allocator&lt;vec3&gt;&gt;, FindValue)
            detected during instantiation of &quot;OutputIterator thrust::copy_if(InputIterator, InputIterator, OutputIterator, Predicate) [with InputIterator=thrust::zip_iterator&lt;thrust::tuple&lt;thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;vec3&gt;&gt;, thrust::detail::normal_iterator&lt;thrust::device_ptr&lt;long&gt;&gt;, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type&gt;&gt;, OutputIterator=thrust::device_vector&lt;vec3, thrust::device_allocator&lt;vec3&gt;&gt;, Predicate=FindValue]&quot; 
  cpp_addin_new2.cu(768): here
  
  3 errors detected in the compilation of &quot;cpp_addin_new2.cu&quot;.
  
  </code></pre>