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

◆ find

auto eve::algo::find = function_with_traits<find_>[find_if.get_traits()]
inlineconstexpr

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

Alternative Header

#include <eve/algo.hpp>

Callable Signatures

namespace eve::algo
{
template <eve::algo::relaxed_range Rng>
}
unaligned_t< iterator_t< R > > unaligned_iterator_t
Unaligned iterator for a relaxed range.
Definition ranges_types.hpp:68
constexpr auto find
a version of find_if with a value to find instead of a predicate to test.
Definition find.hpp:182
typename decltype(detail::value_type_impl< T >())::type value_type_t
A meta function for getting an associated value_type for a relaxed iterator/range.
Definition value_type.hpp:94

Parameters

  • rng: Relaxed input range to process
  • 'v': value to find

Return value

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

See also
find_if

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_if_not
a version of eve::algo::find_if where the preicate is negated
Definition find.hpp:233
constexpr auto find_if
SIMD version of std::find_if.
Definition find.hpp:130
constexpr auto is_eqz
elementwise callable returning a logical true if and only if the element value is zero.
Definition is_eqz.hpp:72