From Jason Turner

[set.union]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkcu9v1j1/{from.md → to.md} +34 -11
tmp/tmpkcu9v1j1/{from.md → to.md} RENAMED
@@ -1,11 +1,11 @@
1
  #### `set_union` <a id="set.union">[[set.union]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2,
5
  class OutputIterator>
6
- OutputIterator
7
  set_union(InputIterator1 first1, InputIterator1 last1,
8
  InputIterator2 first2, InputIterator2 last2,
9
  OutputIterator result);
10
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
11
  class ForwardIterator>
@@ -15,37 +15,60 @@ template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
15
  ForwardIterator2 first2, ForwardIterator2 last2,
16
  ForwardIterator result);
17
 
18
  template<class InputIterator1, class InputIterator2,
19
  class OutputIterator, class Compare>
20
- OutputIterator
21
  set_union(InputIterator1 first1, InputIterator1 last1,
22
  InputIterator2 first2, InputIterator2 last2,
23
  OutputIterator result, Compare comp);
24
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
25
  class ForwardIterator, class Compare>
26
  ForwardIterator
27
  set_union(ExecutionPolicy&& exec,
28
  ForwardIterator1 first1, ForwardIterator1 last1,
29
  ForwardIterator2 first2, ForwardIterator2 last2,
30
  ForwardIterator result, Compare comp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ```
32
 
33
- *Requires:* The resulting range shall not overlap with either of the
 
 
 
 
 
34
  original ranges.
35
 
36
  *Effects:* Constructs a sorted union of the elements from the two
37
  ranges; that is, the set of elements that are present in one or both of
38
  the ranges.
39
 
40
- *Returns:* The end of the constructed range.
 
 
 
 
41
 
42
  *Complexity:* At most `2 * ((last1 - first1) + (last2 - first2)) - 1`
43
- comparisons.
44
 
45
- *Remarks:* If \[`first1`, `last1`) contains m elements that are
46
- equivalent to each other and \[`first2`, `last2`) contains n elements
47
- that are equivalent to them, then all m elements from the first range
48
- shall be copied to the output range, in order, and then max(n - m, 0)
49
- elements from the second range shall be copied to the output range, in
50
- order.
51
 
 
1
  #### `set_union` <a id="set.union">[[set.union]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2,
5
  class OutputIterator>
6
+ constexpr OutputIterator
7
  set_union(InputIterator1 first1, InputIterator1 last1,
8
  InputIterator2 first2, InputIterator2 last2,
9
  OutputIterator result);
10
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
11
  class ForwardIterator>
 
15
  ForwardIterator2 first2, ForwardIterator2 last2,
16
  ForwardIterator result);
17
 
18
  template<class InputIterator1, class InputIterator2,
19
  class OutputIterator, class Compare>
20
+ constexpr OutputIterator
21
  set_union(InputIterator1 first1, InputIterator1 last1,
22
  InputIterator2 first2, InputIterator2 last2,
23
  OutputIterator result, Compare comp);
24
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
25
  class ForwardIterator, class Compare>
26
  ForwardIterator
27
  set_union(ExecutionPolicy&& exec,
28
  ForwardIterator1 first1, ForwardIterator1 last1,
29
  ForwardIterator2 first2, ForwardIterator2 last2,
30
  ForwardIterator result, Compare comp);
31
+
32
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
33
+ weakly_incrementable O, class Comp = ranges::less,
34
+ class Proj1 = identity, class Proj2 = identity>
35
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
36
+ constexpr ranges::set_union_result<I1, I2, O>
37
+ ranges::set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
38
+ Proj1 proj1 = {}, Proj2 proj2 = {});
39
+ template<input_range R1, input_range R2, weakly_incrementable O,
40
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
41
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
42
+ constexpr ranges::set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
43
+ ranges::set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
44
+ Proj1 proj1 = {}, Proj2 proj2 = {});
45
  ```
46
 
47
+ Let `comp` be `less{}`, and `proj1` and `proj2` be `identity{}` for the
48
+ overloads with no parameters by those names.
49
+
50
+ *Preconditions:* The ranges \[`first1`, `last1`) and \[`first2`,
51
+ `last2`) are sorted with respect to `comp` and `proj1` or `proj2`,
52
+ respectively. The resulting range does not overlap with either of the
53
  original ranges.
54
 
55
  *Effects:* Constructs a sorted union of the elements from the two
56
  ranges; that is, the set of elements that are present in one or both of
57
  the ranges.
58
 
59
+ *Returns:* Let `result_last` be the end of the constructed range.
60
+ Returns
61
+
62
+ - `result_last` for the overloads in namespace `std`.
63
+ - `{last1, last2, result_last}` for the overloads in namespace `ranges`.
64
 
65
  *Complexity:* At most `2 * ((last1 - first1) + (last2 - first2)) - 1`
66
+ comparisons and applications of each projection.
67
 
68
+ *Remarks:* Stable [[algorithm.stable]]. If \[`first1`, `last1`) contains
69
+ m elements that are equivalent to each other and \[`first2`, `last2`)
70
+ contains n elements that are equivalent to them, then all m elements
71
+ from the first range are copied to the output range, in order, and then
72
+ the final max(n - m, 0) elements from the second range are copied to the
73
+ output range, in order.
74