From 98445c98ebe6c65f981526fcbd0215d289cf626e Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Tue, 27 Aug 2013 02:16:11 +0900 Subject: [PATCH] fix equal for empty range --- sprout/algorithm/equal.hpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/sprout/algorithm/equal.hpp b/sprout/algorithm/equal.hpp index acb09f44..5d6fe888 100644 --- a/sprout/algorithm/equal.hpp +++ b/sprout/algorithm/equal.hpp @@ -131,24 +131,6 @@ namespace sprout { return sprout::tuples::get<2>(current) && sprout::tuples::get<0>(current) == last1 && sprout::tuples::get<1>(current) == last2; } - template - inline SPROUT_CONSTEXPR bool - equal2_impl_ra( - RandomAccessIterator1 first1, RandomAccessIterator1 last1, RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred, - typename std::iterator_traits::difference_type pivot - ) - { - return pivot == 0 ? pred(*first1, *first2) - : sprout::detail::equal2_impl_ra( - first1, sprout::next(first1, pivot), first2, sprout::next(first2, pivot), pred, - pivot / 2 - ) - && sprout::detail::equal2_impl_ra( - sprout::next(first1, pivot), last1, sprout::next(first2, pivot), last2, pred, - (sprout::distance(first1, last1) - pivot) / 2 - ) - ; - } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::is_constant_distance_iterator::value && sprout::is_constant_distance_iterator::value, @@ -160,10 +142,13 @@ namespace sprout { ) { return sprout::distance(first1, last1) == sprout::distance(first2, last2) - && sprout::detail::equal2_impl_ra( - first1, last1, first2, last2, pred, - sprout::distance(first1, last1) / 2 - ) + && ( + sprout::distance(first1, last1) == 0 + || sprout::detail::equal_impl_ra( + first1, last1, first2, pred, + sprout::distance(first1, last1) / 2 + ) + ) ; }