mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
Merge pull request #23 from kariya-mitsuru/equal
fix sprout::equal for empty range
This commit is contained in:
commit
e01c9ef98d
1 changed files with 7 additions and 22 deletions
|
@ -131,24 +131,6 @@ namespace sprout {
|
||||||
return sprout::tuples::get<2>(current) && sprout::tuples::get<0>(current) == last1 && sprout::tuples::get<1>(current) == last2;
|
return sprout::tuples::get<2>(current) && sprout::tuples::get<0>(current) == last1 && sprout::tuples::get<1>(current) == last2;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename BinaryPredicate>
|
|
||||||
inline SPROUT_CONSTEXPR bool
|
|
||||||
equal2_impl_ra(
|
|
||||||
RandomAccessIterator1 first1, RandomAccessIterator1 last1, RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
|
|
||||||
typename std::iterator_traits<RandomAccessIterator1>::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<typename RandomAccessIterator1, typename RandomAccessIterator2, typename BinaryPredicate>
|
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename BinaryPredicate>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
sprout::is_constant_distance_iterator<RandomAccessIterator1>::value && sprout::is_constant_distance_iterator<RandomAccessIterator2>::value,
|
sprout::is_constant_distance_iterator<RandomAccessIterator1>::value && sprout::is_constant_distance_iterator<RandomAccessIterator2>::value,
|
||||||
|
@ -160,10 +142,13 @@ namespace sprout {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sprout::distance(first1, last1) == sprout::distance(first2, last2)
|
return sprout::distance(first1, last1) == sprout::distance(first2, last2)
|
||||||
&& sprout::detail::equal2_impl_ra(
|
&& (
|
||||||
first1, last1, first2, last2, pred,
|
sprout::distance(first1, last1) == 0
|
||||||
sprout::distance(first1, last1) / 2
|
|| sprout::detail::equal_impl_ra(
|
||||||
)
|
first1, last1, first2, pred,
|
||||||
|
sprout::distance(first1, last1) / 2
|
||||||
|
)
|
||||||
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue