◆ min_element()

template<typename T , typename Comp >
T const* boost::simd::min_element ( T const *  first,
T const *  last,
Comp  comp 

Returns an iterator pointing to the element with the smallest value in the range [first,last).

firstBeginning of the range of elements to min_element
lastEnd of the range of elements to min_element
compcomparison function object that will be applied.
  • first and last must be pointer to Vectorizable type.
  • comp must be a polymorphic unary function object, i.e callable on generic types.
  • if comp is not present the function test is done with operator <
#include <boost/simd/algorithm/min_element.hpp>
#include <boost/simd/function/is_greater.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::min_element( d.data(), d.data()+7);
std::cout << "*r1 " << *r1<< "\n";
auto r2 = bs::min_element( d.data(), d.data()+7, bs::is_greater);
std::cout << "*r2 " << *r2 << "\n";
return 0;
Possible output:
*r1 -1
*r2 2