#include <eve/module/algo/algo/equal.hpp>
a SIMD version of std::equal
Tests wether two ranges are equal (accepts anything that zips together as a range of 2 things) By default aligns and unrolls 4 times.
Alternative Header
namespace eve::algo
{
template <zipped_range_pair Rng>
template <zipped_range_pair Rng, typename P>
bool equal(Rng&& rng, P p);
template<typename R1, typename R2>
bool equal(R1&& r1, R2&& r2)
requires zip_to_range<R1, R2>;
template<typename R1, typename R2, typename P>
bool equal(R1&& r1, R2&& r2, P p)
requires zip_to_range<R1, R2>;
}
constexpr auto equal
a SIMD version of std::equal
Definition: equal.hpp:111
- Compare both halves of zipped_range_pair for equality
- Compare both halves of zipped_range_pair for equivalence using predicate P
- Compare r1 and r2 that zip together to zip_range_pair for equality
- Compare r1 and r2 that zip together to zip_range_pair for equivalence using predicate P
- Note
- 1. and 3. will convert to common type to do equality comparison if necessary to get the same for custom predicate, use
[common_type]
trait on your zip
.
-
to better understand the
zip
interfaces, have a look at examples/algorithms/using_existing/memcmp_...
or examples/algorithms/using_existing/case_insensitive...
.
Parameters
rng
: zipped pair of 2 ranges to compare
- 'r1
,
r2- two separate components that
zipto a
zipped_range_pair *
p` - binary predicate for equivelence testing.
Return value
bool wether any values matched the predicate
#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::vector<int> w = {-9,3,-8,2,2,5,-5,7,-2,3};
std::cout << " -> v = "
<< tts::as_string(v)
<< "\n";
std::cout << " -> w = "
<< tts::as_string(w)
<< "\n";
std::cout <<
" -> eve::algo::equal(v, v) = " << std::boolalpha <<
eve::algo::equal(v, v) <<
"\n";
std::cout <<
" -> eve::algo::equal(v, w) = " << std::boolalpha <<
eve::algo::equal(v, w) <<
"\n";
return 0;
}