From c254846ac265cc2e8631b3b9530c59eef9a911ba Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 26 Nov 2019 07:49:34 +1100 Subject: [PATCH] view: add `equal` overload that takes a parameter --- view.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/view.hpp b/view.hpp index 102e7c58..a0610264 100644 --- a/view.hpp +++ b/view.hpp @@ -792,6 +792,25 @@ namespace cruft { /////////////////////////////////////////////////////////////////////////// + template < + typename BeginA, typename EndA, + typename BeginB, typename EndB, + typename ComparatorT + > + decltype(auto) + equal ( + view const &a, + view const &b, + ComparatorT &&cmp + ) { + return std::equal ( + std::begin (a), std::end (a), + std::begin (b), std::end (b), + std::forward (cmp) + ); + } + + //------------------------------------------------------------------------- template < typename BeginA, typename EndA, typename BeginB, typename EndB @@ -799,8 +818,7 @@ namespace cruft { constexpr bool equal (const view &a, const view &b) { - return a.size () == b.size () && - std::equal (std::begin (a), std::end (a), std::begin (b)); + return ::cruft::equal (a, b, std::equal_to {}); }