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

◆ find_if

auto eve::algo::find_if = function_with_traits<find_if_>[default_simple_algo_traits]
inlineconstexpr

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

Configurable Callable Object performing a SIMD optimized version of the find_if By default, the operation will be unrolled by a factor of 4, and align memory accesses.

Alternative Header

#include <eve/algo.hpp>

Callable Signatures

namespace eve::algo
{
template <eve::algo::relaxed_range Rng, typename P>
auto find_if(Rng&& rng, P p) -> unaligned_iterator_t<Rng>;
}
unaligned_t< iterator_t< R > > unaligned_iterator_t
Unaligned iterator for a relaxed range.
Definition ranges_types.hpp:68
constexpr auto find_if
SIMD version of std::find_if.
Definition find.hpp:130

Parameters

  • rng: Relaxed input range to process
  • 'p': predicate, if true - we found the value.

Return value

Iterator on the element found or past the end if not (same as std)

Example

#include <eve/module/core.hpp>
#include <eve/module/algo.hpp>
#include <tts/tts.hpp>
#include <iostream>
#include <vector>
int main()
{
std::vector<int> v{12, 0, 5, -9, 3, 0, 5};
std::cout << " -> v = "
<< tts::as_string(v)
<< "\n";
std::cout << " <- eve::algo::find_if(v, eve::is_eqz) - v.begin() = " << pos - v.begin() << "\n";
auto posn = eve::algo::find_if_not(v, [](auto x){return x < 0; });
std::cout << " <- eve::algo::find_if_not(v, x < 0) - v.begin() = " << posn - v.begin() << "\n";
auto pos_v = eve::algo::find(v, 5);
std::cout << " <- eve::algo::find(v, 5) - v.begin() = " << pos_v - v.begin() << "\n";
return 0;
}
constexpr auto find
a version of find_if with a value to find instead of a predicate to test.
Definition find.hpp:182
constexpr auto find_if_not
a version of eve::algo::find_if where the preicate is negated
Definition find.hpp:233
constexpr auto is_eqz
elementwise callable returning a logical true if and only if the element value is zero.
Definition is_eqz.hpp:72