diff --git a/sprout/adapt/sscrisk/cel/array.hpp b/sprout/adapt/sscrisk/cel/array.hpp index 8b792ddd..7516ceed 100644 --- a/sprout/adapt/sscrisk/cel/array.hpp +++ b/sprout/adapt/sscrisk/cel/array.hpp @@ -44,7 +44,7 @@ namespace sprout { // template SPROUT_CONSTEXPR typename sprout::container_traits >::const_iterator cbegin(sscrisk::cel::array const& cont) { - return sprout::container_traits >::const_iterator(cont, 0); + return typename sprout::container_traits >::const_iterator(cont, 0); } // diff --git a/sprout/algorithm/binary_search.hpp b/sprout/algorithm/binary_search.hpp index 590e3aa7..57d670c9 100644 --- a/sprout/algorithm/binary_search.hpp +++ b/sprout/algorithm/binary_search.hpp @@ -13,10 +13,10 @@ namespace sprout { SPROUT_CONSTEXPR bool binary_search(ForwardIterator first, ForwardIterator last, T const& value) { return first == last ? false : sprout::next(first) == last ? !(*first < value) && !(value < *first) ? true : false - : *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2) < value - ? sprout::binary_search(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value) - : value < *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)) / 2 - ? sprout::binary_search(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::binary_search(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value) + : value < *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)) / 2 + ? sprout::binary_search(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value) : true ; } @@ -25,10 +25,10 @@ namespace sprout { SPROUT_CONSTEXPR bool binary_search(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) { return first == last ? false : sprout::next(first) == last ? !comp(*first, value) && !comp(value, *first) ? true : false - : comp(*(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value) - ? sprout::binary_search(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value) - : comp(value, *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)) / 2) - ? sprout::binary_search(first, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, value) + : comp(*sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value) + ? sprout::binary_search(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value) + : comp(value, *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)) / 2) + ? sprout::binary_search(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value) : true ; } diff --git a/sprout/algorithm/is_heap_until.hpp b/sprout/algorithm/is_heap_until.hpp index 5056d5a6..78bb9d27 100644 --- a/sprout/algorithm/is_heap_until.hpp +++ b/sprout/algorithm/is_heap_until.hpp @@ -19,7 +19,7 @@ namespace sprout { std::size_t n ) { - return first + n == last || !comp(first[n], first[(n - 1) / 2]) ? first + n + return sprout::next(first, n) == last || !comp(first[n], first[(n - 1) / 2]) ? sprout::next(first, n) : sprout::detail::is_heap_until_impl(first, last, comp, n + 1) ; } diff --git a/sprout/algorithm/is_permutation.hpp b/sprout/algorithm/is_permutation.hpp index 087515d9..357a4a60 100644 --- a/sprout/algorithm/is_permutation.hpp +++ b/sprout/algorithm/is_permutation.hpp @@ -22,7 +22,7 @@ namespace sprout { { return first1_ == last1 ? true : sprout::count(first1, last1, *first1_) - == sprout::count(first2, first2 + NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), *first1_) + == sprout::count(first2, sprout::next(first2, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)), *first1_) && sprout::detail::is_permutation_impl(first1, last1, first2, sprout::next(first1_)) ? true : false @@ -40,7 +40,7 @@ namespace sprout { { return first1_ == last1 ? true : sprout::count_if(first1, last1, NS_SSCRISK_CEL_OR_SPROUT::bind2nd(pred, *first1_)) - == sprout::count_if(first2, first2 + NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), NS_SSCRISK_CEL_OR_SPROUT::bind2nd(pred, *first1_)) + == sprout::count_if(first2, sprout::next(first2, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)), NS_SSCRISK_CEL_OR_SPROUT::bind2nd(pred, *first1_)) && sprout::detail::is_permutation_impl(first1, last1, first2, sprout::next(first1_), pred) ? true : false diff --git a/sprout/algorithm/lower_bound.hpp b/sprout/algorithm/lower_bound.hpp index 0497a1ea..6b67a87d 100644 --- a/sprout/algorithm/lower_bound.hpp +++ b/sprout/algorithm/lower_bound.hpp @@ -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 diff --git a/sprout/algorithm/partition_point.hpp b/sprout/algorithm/partition_point.hpp index 96ed7224..966f166a 100644 --- a/sprout/algorithm/partition_point.hpp +++ b/sprout/algorithm/partition_point.hpp @@ -12,8 +12,18 @@ namespace sprout { template SPROUT_CONSTEXPR ForwardIterator partition_point_impl(ForwardIterator first, ForwardIterator last, Predicate pred, ForwardIterator mid) { return mid == last ? mid - : pred(*mid) ? sprout::detail::partition_point_impl(mid + 1, last, pred, mid + 1 + NS_SSCRISK_CEL_OR_SPROUT::distance(mid + 1, last) / 2) - : sprout::detail::partition_point_impl(first, mid, pred, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, mid) / 2) + : pred(*mid) ? sprout::detail::partition_point_impl( + sprout::next(mid), + last, + pred, + sprout::next(mid, 1 + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::next(mid), last) / 2) + ) + : sprout::detail::partition_point_impl( + first, + mid, + pred, + sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, mid) / 2) + ) ; } } // namespace detail @@ -21,7 +31,7 @@ namespace sprout { // 25.3.13 Partitions template SPROUT_CONSTEXPR ForwardIterator partition_point(ForwardIterator first, ForwardIterator last, Predicate pred) { - return sprout::detail::partition_point_impl(first, last, pred, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2); + return sprout::detail::partition_point_impl(first, last, pred, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)); } } // namespace sprout diff --git a/sprout/algorithm/upper_bound.hpp b/sprout/algorithm/upper_bound.hpp index e54498da..17cb485e 100644 --- a/sprout/algorithm/upper_bound.hpp +++ b/sprout/algorithm/upper_bound.hpp @@ -13,9 +13,9 @@ namespace sprout { SPROUT_CONSTEXPR ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, T const& value) { return first == last ? last : sprout::next(first) == last ? !(value < *first) ? last : first - : !(value < *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)) - ? upper_bound(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value) - : sprout::upper_bound(first, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, value) + : !(value < *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)) + ? upper_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value) + : sprout::upper_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value) ; } @@ -23,9 +23,9 @@ namespace sprout { SPROUT_CONSTEXPR ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) { return first == last ? last : sprout::next(first) == last ? !comp(value, *first) ? last : first - : !comp(value, *(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)) - ? sprout::upper_bound(first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, last, value, comp) - : sprout::upper_bound(first, first + NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, value, comp) + : !comp(value, *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)) + ? sprout::upper_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value, comp) + : sprout::upper_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value, comp) ; } } // namespace sprout