◆ find()

template<typename T , typename U >
T const* boost::simd::find ( T const *  first,
T const *  last,
U const &  val 
)

Returns an iterator to the first element in the range [first,last) for which the element equals val.

If no such element is found, the function returns last.

Parameters
firstBeginning of the range of elements to find
lastEnd of the range of elements to find
valValue to search for in the range.
Requirement
  • first, last and out must be pointer to Vectorizable type.
  • val must be a scalar value convertible to the pointee type of first.
Example:
#include <boost/simd/algorithm/find.hpp>
#include <iostream>
#include <vector>
int main()
{
namespace bs = boost::simd;
std::vector<float> d{ 0.0f, 2.0f, 0.0f, 0.0f, -1.0f, 2.0f, 0.0f};
auto r1 = bs::find( d.data(), d.data()+7, 2.0f );
std::cout << "r1 " << r1 << " *r1 " << *r1 << "\n";
auto r2 = bs::find( d.data(), d.data()+7, -1.0f);
std::cout << "r2 " << r2 << " *r2 " << *r2 << "\n";
return 0;
}
possible output:
r1 0x239ec24 *r1 2
r2 0x239ec30 *r2 -1
Returns
An iterator to the first element in the range that compares equal to val. If no elements match, the function returns last.