◆ max_element()

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

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

firstBeginning of the range of elements to max_element
lastEnd of the range of elements to max_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/max_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::max_element( d.data(), d.data()+7);
std::cout << "*r1 " << *r1<< "\n";
auto r2 = bs::max_element( d.data(), d.data()+7, bs::is_greater);
std::cout << "*r2 " << *r2 << "\n";
return 0;
Possible output:
*r1 2
*r2 -1