tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
equal.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_EQUAL_HPP
4#define TETL_ALGORITHM_EQUAL_HPP
5
11
12namespace etl {
13
17template <typename InputIt1, typename InputIt2, typename Predicate>
18[[nodiscard]] constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate p) -> bool
19{
20 for (; first1 != last1; ++first1, (void)++first2) {
21 if (not p(*first1, *first2)) {
22 return false;
23 }
24 }
25 return true;
26}
27
29template <typename InputIt1, typename InputIt2>
30[[nodiscard]] constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) -> bool
31{
32 return etl::equal(first1, last1, first2, etl::equal_to());
33}
34
36template <typename InputIt1, typename InputIt2, typename Predicate>
37[[nodiscard]] constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Predicate p)
38 -> bool
39{
43
45 if (etl::distance(first1, last1) != etl::distance(first2, last2)) {
46 return false;
47 }
48 }
49 return etl::equal(first1, last1, first2, p);
50}
51
53template <typename InputIt1, typename InputIt2>
54[[nodiscard]] constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
55{
56 return etl::equal(first1, last1, first2, last2, etl::equal_to());
57}
58
59} // namespace etl
60
61#endif // TETL_ALGORITHM_EQUAL_HPP
constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate p) -> bool
Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)),...
Definition equal.hpp:18
constexpr auto distance(It first, It last) -> typename iterator_traits< It >::difference_type
Returns the number of hops from first to last.
Definition distance.hpp:16
Definition adjacent_find.hpp:8
constexpr bool is_base_of_v
Definition is_base_of.hpp:39
Function object for performing comparisons. Unless specialised, invokes operator== on type T....
Definition equal_to.hpp:14
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition iterator_traits.hpp:47
Defines the category of an iterator. Each tag is an empty type and corresponds to one of the five (un...
Definition tags.hpp:36