2012-10-13 03:49:23 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_ONE_OF_HPP
|
|
|
|
#define SPROUT_ALGORITHM_ONE_OF_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/operation.hpp>
|
|
|
|
#include <sprout/algorithm/find_if.hpp>
|
2012-12-09 05:34:14 +00:00
|
|
|
#include <sprout/algorithm/none_of.hpp>
|
2012-10-13 03:49:23 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace detail {
|
|
|
|
template<typename InputIterator, typename Predicate>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
one_of_impl(InputIterator found, InputIterator last, Predicate pred) {
|
|
|
|
return found != last
|
2012-12-09 05:34:14 +00:00
|
|
|
&& sprout::none_of(sprout::next(found), last, pred)
|
2012-10-13 03:49:23 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// one_of
|
|
|
|
//
|
|
|
|
template<typename InputIterator, typename Predicate>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
one_of(InputIterator first, InputIterator last, Predicate pred) {
|
2012-12-09 05:34:14 +00:00
|
|
|
return sprout::detail::one_of_impl(sprout::find_if(first, last, pred), last, pred);
|
2012-10-13 03:49:23 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_ONE_OF_HPP
|