E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ all_of

eve::algo::all_of = function_with_traits<all_of_>[default_simple_algo_traits]
inlineconstexpr

#include <eve/module/algo/algo/all_of.hpp>

Tests if all of the elements in the range match the predicate. by default aligns and unrolls 4 times.

Alternative Header

#include <eve/algo.hpp>

Callable Signatures

namespace eve::algo
{
template <eve::algo::relaxed_range Rng, typename P>
bool all_of(Rng&& rng, P p);
}
constexpr auto all_of
a SIMD version of std::all_of
Definition: all_of.hpp:103

Parameters

  • rng: Relaxed input range to process
  • 'p': Predicate

Return value

true if unary p returns true for all elements in the range, false otherwise. Returns true if the range is empty.

Example

#include <eve/module/core.hpp>
#include <eve/module/algo.hpp>
#include <iostream>
#include <vector>
#include <tts/tts.hpp>
int main()
{
std::vector<int> v = {2,5,-9,3,-8,2,-5,7,-2,3};
std::cout << " -> v = "
<< tts::as_string(v)
<< "\n";
std::cout << " -> eve::algo::all_of(v, i*i >= 4) = "
<< std::boolalpha << eve::algo::all_of(v, [](auto i){ return i*i >= 4; })<< "\n";
std::cout << " -> eve::algo::all_of(v, eve::is_ltz) = "
<< std::boolalpha << eve::algo::all_of(v, eve::is_ltz)<< "\n";
return 0;
}
constexpr auto is_ltz
elementwise callable returning a logical true if and only if the element value is less than 0.
Definition: is_ltz.hpp:71