From Jason Turner

[alg.count]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxh_m8nwo/{from.md → to.md} +35 -7
tmp/tmpxh_m8nwo/{from.md → to.md} RENAMED
@@ -1,25 +1,53 @@
1
  ### Count <a id="alg.count">[[alg.count]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
- typename iterator_traits<InputIterator>::difference_type
6
  count(InputIterator first, InputIterator last, const T& value);
7
  template<class ExecutionPolicy, class ForwardIterator, class T>
8
  typename iterator_traits<ForwardIterator>::difference_type
9
- count(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& value);
 
10
 
11
  template<class InputIterator, class Predicate>
12
- typename iterator_traits<InputIterator>::difference_type
13
  count_if(InputIterator first, InputIterator last, Predicate pred);
14
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
15
  typename iterator_traits<ForwardIterator>::difference_type
16
- count_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ```
18
 
 
 
 
 
 
 
 
 
 
 
19
  *Effects:* Returns the number of iterators `i` in the range \[`first`,
20
- `last`) for which the following corresponding conditions hold:
21
- `*i == value, pred(*i) != false`.
22
 
23
  *Complexity:* Exactly `last - first` applications of the corresponding
24
- predicate.
25
 
 
1
  ### Count <a id="alg.count">[[alg.count]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
+ constexpr typename iterator_traits<InputIterator>::difference_type
6
  count(InputIterator first, InputIterator last, const T& value);
7
  template<class ExecutionPolicy, class ForwardIterator, class T>
8
  typename iterator_traits<ForwardIterator>::difference_type
9
+ count(ExecutionPolicy&& exec,
10
+ ForwardIterator first, ForwardIterator last, const T& value);
11
 
12
  template<class InputIterator, class Predicate>
13
+ constexpr typename iterator_traits<InputIterator>::difference_type
14
  count_if(InputIterator first, InputIterator last, Predicate pred);
15
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
16
  typename iterator_traits<ForwardIterator>::difference_type
17
+ count_if(ExecutionPolicy&& exec,
18
+ ForwardIterator first, ForwardIterator last, Predicate pred);
19
+
20
+ template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
21
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
22
+ constexpr iter_difference_t<I>
23
+ ranges::count(I first, S last, const T& value, Proj proj = {});
24
+ template<input_range R, class T, class Proj = identity>
25
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
26
+ constexpr range_difference_t<R>
27
+ ranges::count(R&& r, const T& value, Proj proj = {});
28
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
29
+ indirect_unary_predicate<projected<I, Proj>> Pred>
30
+ constexpr iter_difference_t<I>
31
+ ranges::count_if(I first, S last, Pred pred, Proj proj = {});
32
+ template<input_range R, class Proj = identity,
33
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
34
+ constexpr range_difference_t<R>
35
+ ranges::count_if(R&& r, Pred pred, Proj proj = {});
36
  ```
37
 
38
+ Let E be:
39
+
40
+ - `*i == value` for the overloads with no parameter `pred` or `proj`;
41
+ - `pred(*i) != false` for the overloads with a parameter `pred` but no
42
+ parameter `proj`;
43
+ - `invoke(proj, *i) == value` for the overloads with a parameter `proj`
44
+ but no parameter `pred`;
45
+ - `bool(invoke(pred, invoke(proj, *i)))` for the overloads with both
46
+ parameters `proj` and `pred`.
47
+
48
  *Effects:* Returns the number of iterators `i` in the range \[`first`,
49
+ `last`) for which E holds.
 
50
 
51
  *Complexity:* Exactly `last - first` applications of the corresponding
52
+ predicate and any projection.
53