mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
porting sscrisk/CEL
This commit is contained in:
parent
ad60c8c530
commit
db20f64991
181 changed files with 2531 additions and 607 deletions
28
sprout/algorithm/partition_point.hpp
Normal file
28
sprout/algorithm/partition_point.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef SPROUT_ALGORITHM_PARTITION_POINT_HPP
|
||||
#define SPROUT_ALGORITHM_PARTITION_POINT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
template<typename ForwardIterator, typename Predicate>
|
||||
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)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// 25.3.13 Partitions
|
||||
template<typename ForwardIterator, typename Predicate>
|
||||
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);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_PARTITION_POINT_HPP
|
Loading…
Add table
Add a link
Reference in a new issue