title: Thrust vectorized search: Efficiently combine lower_bound and binary_search to find both position and existence
body: <p>I'm trying to use Thrust to detect if each element of an array can be found in another array and where (both arrays are sorted). I came across the vectorized search routines (lower_bound and binary_search).</p>
  
  <p>lower_bound will return for each value the index where it could be inserted in a list respecting its ordering.</p>
  
  <p>I also need to know if the value is found or not (which can be done with binary_search), not just its position. </p>
  
  <p>Is it possible to achieve both efficiently without making two searches (calling binary_search and then lower_bound)?</p>
  
  <p>I know in the scalar case, lower_bound will return a pointer to end of the array if a value cannot be found, but this does not happens in the vectorized version.</p>
  
  <p>Thanks!</p>