| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- //
- // equal.h
- // stream
- //
- // Created by Sam Jaffe on 4/2/23.
- //
- #pragma once
- #include <stream/forward.h>
- #include <stream/detail/invoke.h>
- #include <stream/detail/traits.h>
- #include <stream/detail/macro.h>
- namespace stream::range {
- template <typename It1, typename S1, typename It2, typename S2,
- typename Cmp = std::equal_to<>, typename Proj1 = detail::identity,
- typename Proj2 = detail::identity,
- REQUIRES((detail::is_comparable_v<It1, S1> &&
- detail::is_comparable_v<It2, S2>))>
- bool equal(It1 it1, S1 end1, It2 it2, S2 end2, Cmp cmp = {}, Proj1 proj1 = {},
- Proj2 proj2 = {}) {
- for (; it1 != end1 && it2 != end2; ++it1, ++it2) {
- if (!detail::invoke(cmp, *it1, *it2, proj1, proj2)) { return false; }
- }
- return (it1 == end1) && (it2 == end2);
- }
- template <typename R1, typename R2, typename Cmp = std::equal_to<>,
- typename Proj1 = detail::identity, typename Proj2 = detail::identity>
- bool equal(R1 const r1, R2 const & r2, Cmp cmp = {}, Proj1 proj1 = {},
- Proj2 proj2 = {}) {
- return equal(r1.begin(), r1.end(), r2.begin(), r2.end(), cmp, proj1, proj2);
- }
- }
- #include <stream/detail/undef.h>
|