From Jason Turner

[alg.find]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3tuwi5u5/{from.md → to.md} +38 -8
tmp/tmp3tuwi5u5/{from.md → to.md} RENAMED
@@ -1,33 +1,63 @@
1
  ### Find <a id="alg.find">[[alg.find]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
- InputIterator find(InputIterator first, InputIterator last,
6
  const T& value);
7
  template<class ExecutionPolicy, class ForwardIterator, class T>
8
  ForwardIterator find(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
9
  const T& value);
10
 
11
  template<class InputIterator, class Predicate>
12
- InputIterator find_if(InputIterator first, InputIterator last,
13
  Predicate pred);
14
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
15
  ForwardIterator find_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
16
  Predicate pred);
17
 
18
  template<class InputIterator, class Predicate>
19
- InputIterator find_if_not(InputIterator first, InputIterator last,
20
  Predicate pred);
21
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
22
- ForwardIterator find_if_not(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
 
23
  Predicate pred);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  ```
25
 
 
 
 
 
 
 
 
 
 
26
  *Returns:* The first iterator `i` in the range \[`first`, `last`) for
27
- which the following corresponding conditions hold: `*i == value`,
28
- `pred(*i) != false`, `pred(*i) == false`. Returns `last` if no such
29
- iterator is found.
30
 
31
  *Complexity:* At most `last - first` applications of the corresponding
32
- predicate.
33
 
 
1
  ### Find <a id="alg.find">[[alg.find]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
+ constexpr InputIterator find(InputIterator first, InputIterator last,
6
  const T& value);
7
  template<class ExecutionPolicy, class ForwardIterator, class T>
8
  ForwardIterator find(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
9
  const T& value);
10
 
11
  template<class InputIterator, class Predicate>
12
+ constexpr InputIterator find_if(InputIterator first, InputIterator last,
13
  Predicate pred);
14
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
15
  ForwardIterator find_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
16
  Predicate pred);
17
 
18
  template<class InputIterator, class Predicate>
19
+ constexpr InputIterator find_if_not(InputIterator first, InputIterator last,
20
  Predicate pred);
21
  template<class ExecutionPolicy, class ForwardIterator, class Predicate>
22
+ ForwardIterator find_if_not(ExecutionPolicy&& exec,
23
+ ForwardIterator first, ForwardIterator last,
24
  Predicate pred);
25
+
26
+ template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
27
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
28
+ constexpr I ranges::find(I first, S last, const T& value, Proj proj = {});
29
+ template<input_range R, class T, class Proj = identity>
30
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
31
+ constexpr borrowed_iterator_t<R>
32
+ ranges::find(R&& r, const T& value, Proj proj = {});
33
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
34
+ indirect_unary_predicate<projected<I, Proj>> Pred>
35
+ constexpr I ranges::find_if(I first, S last, Pred pred, Proj proj = {});
36
+ template<input_range R, class Proj = identity,
37
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
38
+ constexpr borrowed_iterator_t<R>
39
+ ranges::find_if(R&& r, Pred pred, Proj proj = {});
40
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
41
+ indirect_unary_predicate<projected<I, Proj>> Pred>
42
+ constexpr I ranges::find_if_not(I first, S last, Pred pred, Proj proj = {});
43
+ template<input_range R, class Proj = identity,
44
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
45
+ constexpr borrowed_iterator_t<R>
46
+ ranges::find_if_not(R&& r, Pred pred, Proj proj = {});
47
  ```
48
 
49
+ Let E be:
50
+
51
+ - `*i == value` for `find`;
52
+ - `pred(*i) != false` for `find_if`;
53
+ - `pred(*i) == false` for `find_if_not`;
54
+ - `bool(invoke(proj, *i) == value)` for `ranges::find`;
55
+ - `bool(invoke(pred, invoke(proj, *i)))` for `ranges::find_if`;
56
+ - `bool(!invoke(pred, invoke(proj, *i)))` for `ranges::find_if_not`.
57
+
58
  *Returns:* The first iterator `i` in the range \[`first`, `last`) for
59
+ which E is `true`. Returns `last` if no such iterator is found.
 
 
60
 
61
  *Complexity:* At most `last - first` applications of the corresponding
62
+ predicate and any projection.
63