Loading [MathJax]/extensions/tex2jax.js
E.V.E
v2023.02.15
 
All Classes Namespaces Functions Variables Typedefs Enumerations Friends Modules Pages Concepts
Loading...
Searching...
No Matches

◆ equal

eve::algo::equal = function_with_traits<equal_>[all_of.get_traits()]
inlineconstexpr

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

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

#include <eve/algo.hpp>

Callable Signatures

namespace eve::algo
{
template <zipped_range_pair Rng>
bool equal(Rng&& rng); // 1
template <zipped_range_pair Rng, typename P>
bool equal(Rng&& rng, P p); // 2
template<typename R1, typename R2>
bool equal(R1&& r1, R2&& r2) requires zip_to_range<R1, R2>; // 3
template<typename R1, typename R2, typename P>
bool equal(R1&& r1, R2&& r2, P p) requires zip_to_range<R1, R2>; // 4
}
constexpr auto equal
a SIMD version of std::equal
Definition: equal.hpp:111
  1. Compare both halves of zipped_range_pair for equality
  2. Compare both halves of zipped_range_pair for equivalence using predicate P
  3. Compare r1 and r2 that zip together to zip_range_pair for equality
  4. 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 thatzipto azipped_range_pair *p` - binary predicate for equivelence testing.

Return value

bool wether any values matched the predicate

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::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;
}