◆ all_of() [1/2]

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

Returns true if pred evaluates to true for all the elements in the ContiguousRange [first,last) or if the range is empty, and false otherwise.

Parameters
firstBeginning of the range of elements to test
lastEnd of the range of elements to all_of
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/all_of.hpp>
#include <boost/simd/function/is_gtz.hpp>
#include <iostream>
#include <vector>
int main()
{
namespace bs = boost::simd;
std::vector<float> d{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f};
auto rt = bs::all_of( d.data(), d.data()+7, bs::is_gtz );
std::cout << "rt " << rt << "\n";
d[4] = 0.0f;
auto rf = bs::all_of( d.data(), d.data()+7, bs::is_gtz);
std::cout << "rf " << rf << "\n";
return 0;
}
Possible output:
rt 1
rf 0