From Jason Turner

[equal.range]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphkucllxw/{from.md → to.md} +29 -15
tmp/tmphkucllxw/{from.md → to.md} RENAMED
@@ -1,37 +1,51 @@
1
  #### `equal_range` <a id="equal.range">[[equal.range]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator, class T>
5
- pair<ForwardIterator, ForwardIterator>
6
  equal_range(ForwardIterator first,
7
  ForwardIterator last, const T& value);
8
 
9
  template<class ForwardIterator, class T, class Compare>
10
- pair<ForwardIterator, ForwardIterator>
11
  equal_range(ForwardIterator first,
12
  ForwardIterator last, const T& value,
13
  Compare comp);
 
 
 
 
 
 
 
 
 
 
14
  ```
15
 
16
- *Requires:* The elements `e` of \[`first`, `last`) shall be partitioned
17
- with respect to the expressions `e < value` and `!(value < e)` or
18
- `comp(e, value)` and `!comp(value, e)`. Also, for all elements `e` of
19
- `[first, last)`, `e < value` shall imply `!(value < e)` or
20
- `comp(e, value)` shall imply `!comp(value, e)`.
 
 
 
 
21
 
22
  *Returns:*
23
 
 
24
  ``` cpp
25
- make_pair(lower_bound(first, last, value),
26
- upper_bound(first, last, value))
27
  ```
28
-
29
- or
30
-
31
  ``` cpp
32
- make_pair(lower_bound(first, last, value, comp),
33
- upper_bound(first, last, value, comp))
34
  ```
35
 
36
- *Complexity:* At most 2 * log₂(`last - first`) + 𝑂(1) comparisons.
 
37
 
 
1
  #### `equal_range` <a id="equal.range">[[equal.range]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator, class T>
5
+ constexpr pair<ForwardIterator, ForwardIterator>
6
  equal_range(ForwardIterator first,
7
  ForwardIterator last, const T& value);
8
 
9
  template<class ForwardIterator, class T, class Compare>
10
+ constexpr pair<ForwardIterator, ForwardIterator>
11
  equal_range(ForwardIterator first,
12
  ForwardIterator last, const T& value,
13
  Compare comp);
14
+
15
+ template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
16
+ indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
17
+ constexpr subrange<I>
18
+ ranges::equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {});
19
+ template<forward_range R, class T, class Proj = identity,
20
+ indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
21
+ ranges::less>
22
+ constexpr borrowed_subrange_t<R>
23
+ ranges::equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {});
24
  ```
25
 
26
+ Let `comp` be `less{}` and `proj` be `identity{}` for overloads with no
27
+ parameters by those names.
28
+
29
+ *Preconditions:* The elements `e` of \[`first`, `last`) are partitioned
30
+ with respect to the expressions
31
+ `bool(invoke(comp, invoke(proj, e), value))` and
32
+ `!bool(invoke(comp, value, invoke(proj, e)))`. Also, for all elements
33
+ `e` of `[first, last)`, `bool(comp(e, value))` implies
34
+ `!bool(comp(value, e))` for the overloads in namespace `std`.
35
 
36
  *Returns:*
37
 
38
+ - For the overloads in namespace `std`:
39
  ``` cpp
40
+ {lower_bound(first, last, value, comp),
41
+ upper_bound(first, last, value, comp)}
42
  ```
43
+ - For the overloads in namespace `ranges`:
 
 
44
  ``` cpp
45
+ {ranges::lower_bound(first, last, value, comp, proj),
46
+ ranges::upper_bound(first, last, value, comp, proj)}
47
  ```
48
 
49
+ *Complexity:* At most 2 * log₂(`last - first`) + 𝑂(1) comparisons and
50
+ projections.
51