1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-07-02 14:04:09 +00:00

fix non-modidying operation algorithm iteration

This commit is contained in:
bolero-MURAKAMI 2012-04-03 21:58:23 +09:00
parent db20f64991
commit cf593ffeff
7 changed files with 37 additions and 27 deletions

View file

@ -13,9 +13,9 @@ namespace sprout {
SPROUT_CONSTEXPR ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, T const& value) {
return first == last ? last
: sprout::next(first) == last ? *first < value ? last : first
: *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2) < value
? sprout::lower_bound(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value)
: sprout::lower_bound(first, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, value)
: *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2) < value
? sprout::lower_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value)
: sprout::lower_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value)
;
}
@ -23,9 +23,9 @@ namespace sprout {
SPROUT_CONSTEXPR ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) {
return first == last ? last
: sprout::next(first) == last ? comp(*first, value) ? last : first
: comp(*(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value)
? sprout::lower_bound(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value, comp)
: sprout::lower_bound(first, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, value, comp)
: comp(*sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value)
? sprout::lower_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value, comp)
: sprout::lower_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value, comp)
;
}
} // namespace sprout