From Jason Turner

[alg.generate]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpsacoa7y_/{from.md → to.md} +21 -14
tmp/tmpsacoa7y_/{from.md → to.md} RENAMED
@@ -1,34 +1,41 @@
1
  ### Generate <a id="alg.generate">[[alg.generate]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator, class Generator>
5
- void generate(ForwardIterator first, ForwardIterator last,
6
  Generator gen);
7
  template<class ExecutionPolicy, class ForwardIterator, class Generator>
8
  void generate(ExecutionPolicy&& exec,
9
  ForwardIterator first, ForwardIterator last,
10
  Generator gen);
11
 
12
  template<class OutputIterator, class Size, class Generator>
13
- OutputIterator generate_n(OutputIterator first, Size n, Generator gen);
14
  template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
15
  ForwardIterator generate_n(ExecutionPolicy&& exec,
16
  ForwardIterator first, Size n, Generator gen);
 
 
 
 
 
 
 
 
 
 
17
  ```
18
 
19
- *Requires:* `gen` takes no arguments, `Size` shall be convertible to an
20
- integral type ([[conv.integral]], [[class.conv]]).
21
 
22
- *Effects:* The `generate` algorithms invoke the function object `gen`
23
- and assign the return value of `gen` through all the iterators in the
24
- range \[`first`, `last`). The `generate_n` algorithms invoke the
25
- function object `gen` and assign the return value of `gen` through all
26
- the iterators in the range \[`first`, `first + n`) if `n` is positive,
27
- otherwise they do nothing.
28
 
29
- *Returns:* `generate_n` returns `first + n` for non-negative values of
30
- `n` and `first` for negative values.
31
 
32
- *Complexity:* Exactly `last - first`, `n`, or 0 invocations of `gen` and
33
- assignments, respectively.
 
34
 
 
1
  ### Generate <a id="alg.generate">[[alg.generate]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator, class Generator>
5
+ constexpr void generate(ForwardIterator first, ForwardIterator last,
6
  Generator gen);
7
  template<class ExecutionPolicy, class ForwardIterator, class Generator>
8
  void generate(ExecutionPolicy&& exec,
9
  ForwardIterator first, ForwardIterator last,
10
  Generator gen);
11
 
12
  template<class OutputIterator, class Size, class Generator>
13
+ constexpr OutputIterator generate_n(OutputIterator first, Size n, Generator gen);
14
  template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
15
  ForwardIterator generate_n(ExecutionPolicy&& exec,
16
  ForwardIterator first, Size n, Generator gen);
17
+
18
+ template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
19
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
20
+ constexpr O ranges::generate(O first, S last, F gen);
21
+ template<class R, copy_constructible F>
22
+ requires invocable<F&> && output_range<R, invoke_result_t<F&>>
23
+ constexpr borrowed_iterator_t<R> ranges::generate(R&& r, F gen);
24
+ template<input_or_output_iterator O, copy_constructible F>
25
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
26
+ constexpr O ranges::generate_n(O first, iter_difference_t<O> n, F gen);
27
  ```
28
 
29
+ Let N be max(0, `n`) for the `generate_n` algorithms, and `last - first`
30
+ for the `generate` algorithms.
31
 
32
+ *Mandates:* `Size` is convertible to an integral
33
+ type ([[conv.integral]], [[class.conv]]).
 
 
 
 
34
 
35
+ *Effects:* Assigns the result of successive evaluations of `gen()`
36
+ through each iterator in the range \[`first`, `first + `N).
37
 
38
+ *Returns:* `first + `N.
39
+
40
+ *Complexity:* Exactly N evaluations of `gen()` and assignments.
41