◆ equal() [2/2]

template<typename T , typename Pred >
bool boost::simd::equal ( T const *  first1,
T const *  last1,
T const *  first2,
Pred const &  f 
)

Returns true if all the pairs in the range [first1, last1) and the range [first2, first2 + (last1 - first1)), satisfy f and false otherwise.

Parameters
first1,last1- the first range of the elements to compare
first2- the beginning of the second range of the elements to compare
fbinary predicate operation function object that will be applied.
Requirement
  • first, last and out must be pointer to Vectorizable type.
  • f must be a polymorphic binary function object, i.e callable on generic types.
  • boost::simd::pack<T1> and boost::simd::pack<T2> must have the same cardinal.
Example:
#include <boost/simd/algorithm/equal.hpp>
#include <boost/simd/function/inc.hpp>
#include <iostream>
#include <vector>
struct f
{
template<typename T> auto operator()(T const& a, T const& b) const -> decltype(a == boost::simd::inc(b))
{
return (a == boost::simd::inc(b));
}
};
int main()
{
std::vector<float> d{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f};
std::vector<float> e{0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f};
bool bf = boost::simd::equal( d.data(), d.data()+7, e.data());
bool bt = boost::simd::equal( d.data(), d.data()+7, d.data());
bool bt1 = boost::simd::equal( d.data(), d.data()+7, e.data(), f{});
std::cout << "bf " << bf << '\n';
std::cout << "bt " << bt << '\n';
std::cout << "bt1 " << bt1 << '\n';
return 0;
}
Possible output:
bf 0
bt 1
bt1 1