| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Non-modifying sequence operations | |||||||||||||
| |||||||||||||
| Modifying sequence operations | |||||||||||||
| Partitioning operations | |||||||||||||
| Sorting operations | |||||||||||||
| Binary search operations | |||||||||||||
| Set operations (on sorted ranges) | |||||||||||||
| Heap operations | |||||||||||||
| Minimum/maximum operations | |||||||||||||
| Permutations | |||||||||||||
Defined in header <experimental/ranges/algorithm> | ||
template< InputIterator I, Sentinel<I> S,class T,class Proj=ranges::identity> requires IndirectRelation<ranges::equal_to<>,projected<I, Proj>,const T*> | (1) | (ranges TS) |
template< InputRange R,class T,class Proj=ranges::identity> requires IndirectRelation<ranges::equal_to<>, | (2) | (ranges TS) |
template< InputIterator I, Sentinel<I> S,class Proj=ranges::identity, IndirectUnaryPredicate<projected<I, Proj>> Pred> | (3) | (ranges TS) |
template< InputRange R,class Proj=ranges::identity, IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred> | (4) | (ranges TS) |
Returns the number of elements in the range[first, last) satisfying specific criteria.
Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.
Contents |
| first, last | - | the range of elements to examine |
| r | - | the range of elements to examine |
| value | - | the value to search for |
| pred | - | predicate to apply to the projected elements |
| proj | - | projection to apply to the elements |
Number of elements satisfying the condition.
Exactlylast -first comparisons / applications of the predicate, and the same number of applications of the projection.
For the number of elements in the range[first, last) without any additional criteria, seeranges::distance.
| First version |
|---|
template<InputIterator I, Sentinel<I> S,class T,class Proj=ranges::identity> requires IndirectRelation<ranges::equal_to<>,projected<I, Proj>,const T*>ranges::difference_type_t<I> count(I first, S last,const T& value, Proj proj= Proj{}){ ranges::difference_type_t<I> ret=0;for(; first!= last;++first)if(ranges::invoke(proj,*first)== value)++ret;return ret;} |
| Second version |
template<InputIterator I, Sentinel<I> S,class Proj=ranges::identity, IndirectUnaryPredicate<projected<I, Proj>> Pred>ranges::difference_type_t<I> count_if(I first, S last, Pred pred, Proj proj= Proj{}){ ranges::difference_type_t<I> ret=0;for(; first!= last;++first)if(ranges::invoke(pred,ranges::invoke(proj,*i)))++ret;return ret;} |
| This section is incomplete Reason: no example |
| returns the number of elements satisfying specific criteria (function template)[edit] | |
| returns the distance between an iterator and a sentinel, or between the beginning and the end of a range (function template)[edit] |