◆ any_of() [1/2]

template<typename T , typename Pred >
bool boost::simd::any_of ( T const *  first,
T const *  last,
Pred const &  pred 
)

Returns @ true if pred avaluates to true for any of the elements in the ContiguousRange [first,last), and ^c false otherwise (in particular when the range is empty).

Parameters
firstBeginning of the range of elements to test
lastEnd of the range of elements to test
predPredicate function object that will be applied.
Requirement
  • first and last must be pointers to Vectorizable type.
  • pred must be a polymorphic unary function object, i.e callable on generic types.
Example:
#include <boost/simd/algorithm/any_of.hpp>
#include <boost/simd/function/is_gtz.hpp>
#include <iostream>
#include <vector>
int main()
{
namespace bs = boost::simd;
std::vector<float> d{ 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
auto rt1 = bs::any_of( d.data(), d.data()+7, bs::is_gtz );
std::cout << "rt1 " << rt1 << "\n";
auto rf1 = bs::any_of( d.data(), d.data()+7, bs::is_ltz);
std::cout << "rf1 " << rf1 << "\n";
auto rt2 = bs::any_of( d.data()+1, d.data()+8);
std::cout << "rt2 " << rt2 << "\n";
auto rf2 = bs::any_of( d.data()+2, d.data()+9, bs::is_nez);
std::cout << "rf2 " << rf2 << "\n";
return 0;
}
Possible output:
rt1 1
rf1 0
rt2 1
rf2 0