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

◆ any_of

auto eve::algo::any_of = function_with_traits<any_of_>[default_simple_algo_traits]
inlineconstexpr

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

Tests if any 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 any_of(Rng&& rng, P p);
}
constexpr auto any_of
a SIMD version of std::any_of
Definition any_of.hpp:104

Parameters

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

Return value

true if p returns true for at least one element in the range, false otherwise. Returns false 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,6,-10,32,-8,2,-6,8,-2,4};
std::cout << " -> v = "
<< tts::as_string(v)
<< "\n";
std::cout << " -> eve::algo::any_of(v, i >= 4) = "
<< std::boolalpha << eve::algo::any_of(v, [](auto i){ return i >= 4; })<< "\n";
std::cout << " -> eve::algo::any_of(v, eve::is_odd) = "
<< std::boolalpha << eve::algo::any_of(v, eve::is_odd)<< "\n";
return 0;
}
constexpr auto is_odd
elementwise callable returning a logical true if and only if the element value is odd.
Definition is_odd.hpp:73