// // equal.h // stream // // Created by Sam Jaffe on 4/2/23. // #pragma once #include #include #include #include namespace stream::range { template , typename Proj1 = detail::identity, typename Proj2 = detail::identity, REQUIRES((detail::is_comparable_v && detail::is_comparable_v))> bool equal(It1 it1, S1 end1, It2 it2, S2 end2, Cmp cmp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) { if constexpr (detail::is_sized_sentinel_v && detail::is_sized_sentinel_v) { if ((end1 - it1) != (end2 - it2)) { return false; } } for (; it1 != end1 && it2 != end2; ++it1, ++it2) { if (!detail::invoke(cmp, *it1, *it2, proj1, proj2)) { return false; } } return (it1 == end1) && (it2 == end2); } template , 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(), std::ref(cmp), std::ref(proj1), std::ref(proj2)); } } #include