tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
mismatch.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_MISMATCH_HPP
4#define TETL_ALGORITHM_MISMATCH_HPP
5
7
8namespace etl {
9
24template <typename InputIt1, typename InputIt2, typename Predicate>
25[[nodiscard]] constexpr auto mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate pred)
27{
28 for (; first1 != last1; ++first1, (void)++first2) {
29 if (not pred(*first1, *first2)) {
30 break;
31 }
32 }
33
34 return {first1, first2};
35}
36
37template <typename InputIt1, typename InputIt2>
38[[nodiscard]] constexpr auto mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2) -> pair<InputIt1, InputIt2>
39{
40 return etl::mismatch(first1, last1, first2, etl::equal_to());
41}
42
43template <typename InputIt1, typename InputIt2, typename Predicate>
44[[nodiscard]] constexpr auto mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Predicate pred)
46{
47 for (; first1 != last1 and first2 != last2; ++first1, (void)++first2) {
48 if (not pred(*first1, *first2)) {
49 break;
50 }
51 }
52
53 return {first1, first2};
54}
55
56template <typename InputIt1, typename InputIt2>
57[[nodiscard]] constexpr auto mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
59{
60 return etl::mismatch(first1, last1, first2, last2, etl::equal_to());
61}
62
63} // namespace etl
64
65#endif // TETL_ALGORITHM_MISMATCH_HPP
constexpr auto mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate pred) -> pair< InputIt1, InputIt2 >
Returns the first mismatching pair of elements from two ranges: one defined by [first1,...
Definition mismatch.hpp:25
Definition adjacent_find.hpp:8
Function object for performing comparisons. Unless specialised, invokes operator== on type T....
Definition equal_to.hpp:14
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36