2012-04-01 13:15:09 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_ADJACENT_FIND_HPP
|
|
|
|
#define SPROUT_ALGORITHM_ADJACENT_FIND_HPP
|
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/operation.hpp>
|
|
|
|
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
// Copyright (C) 2011 RiSK (sscrisk)
|
|
|
|
|
|
|
|
// 25.2.8 Adjacent find
|
|
|
|
template<typename ForwardIterator, typename BinaryPredicate>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR ForwardIterator
|
|
|
|
adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
|
2012-04-01 13:15:09 +00:00
|
|
|
return first == last || sprout::next(first) == last ? last
|
|
|
|
: pred(*first, *(sprout::next(first))) != false ? first
|
|
|
|
: sprout::adjacent_find(sprout::next(first), last, pred)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ForwardIterator>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR ForwardIterator
|
|
|
|
adjacent_find(ForwardIterator first, ForwardIterator last) {
|
2012-04-01 13:15:09 +00:00
|
|
|
return sprout::adjacent_find(
|
2012-10-06 04:53:07 +00:00
|
|
|
first, last,
|
2012-04-01 13:15:09 +00:00
|
|
|
NS_SSCRISK_CEL_OR_SPROUT::equal_to<typename std::iterator_traits<ForwardIterator>::value_type>()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_ADJACENT_FIND_HPP
|