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
21
sprout/algorithm/count_if.hpp
Normal file
21
sprout/algorithm/count_if.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef SPROUT_ALGORITHM_COUNT_IF_HPP
|
||||
#define SPROUT_ALGORITHM_COUNT_IF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
// 25.2.9 Count
|
||||
template<typename InputIterator, typename Predicate>
|
||||
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_if(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? 0
|
||||
: (pred(*first) != false ? 1 : 0) + sprout::count_if(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_COUNT_IF_HPP
|
Loading…
Add table
Add a link
Reference in a new issue