From Jason Turner

[alg.rand.generate]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpeyerdmr_/{from.md → to.md} +91 -0
tmp/tmpeyerdmr_/{from.md → to.md} RENAMED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### `generate_random` <a id="alg.rand.generate">[[alg.rand.generate]]</a>
2
+
3
+ ``` cpp
4
+ template<class R, class G>
5
+ requires output_range<R, invoke_result_t<G&>> && uniform_random_bit_generator<remove_cvref_t<G>>
6
+ constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g);
7
+ ```
8
+
9
+ *Effects:*
10
+
11
+ - Calls `g.generate_random(std::forward<R>(r))` if this expression is
12
+ well-formed.
13
+ - Otherwise, if `R` models `sized_range`, fills `r` with
14
+ `ranges::size(r)` values of type `invoke_result_t<G&>` by performing
15
+ an unspecified number of invocations of the form `g()` or
16
+ `g.generate_random(s)`, if such an expression is well-formed for a
17
+ value `N` and an object `s` of type `span<invoke_result_t<G&>, N>`.
18
+ \[*Note 1*: Values of `N` can differ between
19
+ invocations. — *end note*]
20
+ - Otherwise, calls `ranges::generate(std::forward<R>(r), ref(g))`.
21
+
22
+ *Returns:* `ranges::end(r)`.
23
+
24
+ *Remarks:* The effects of `generate_random(r, g)` shall be equivalent to
25
+ `ranges::generate(std::forward<R>(r), ref(g))`.
26
+
27
+ [*Note 1*: This implies that `g.generate_random(a)` fills `a` with the
28
+ same values as produced by invocation of `g()`. — *end note*]
29
+
30
+ ``` cpp
31
+ template<class G, output_iterator<invoke_result_t<G&>> O, sentinel_for<O> S>
32
+ requires uniform_random_bit_generator<remove_cvref_t<G>>
33
+ constexpr O ranges::generate_random(O first, S last, G&& g);
34
+ ```
35
+
36
+ *Effects:* Equivalent to:
37
+
38
+ ``` cpp
39
+ return generate_random(subrange<O, S>(std::move(first), last), g);
40
+ ```
41
+
42
+ ``` cpp
43
+ template<class R, class G, class D>
44
+ requires output_range<R, invoke_result_t<D&, G&>> && invocable<D&, G&> &&
45
+ uniform_random_bit_generator<remove_cvref_t<G>> &&
46
+ is_arithmetic_v<invoke_result_t<D&, G&>>
47
+ constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g, D&& d);
48
+ ```
49
+
50
+ *Effects:*
51
+
52
+ - Calls `d.generate_random(std::forward<R>(r), g)` if this expression is
53
+ well-formed.
54
+ - Otherwise, if `R` models `sized_range`, fills `r` with
55
+ `ranges::size(r)` values of type `invoke_result_t<D&, G&>` by
56
+ performing an unspecified number of invocations of the form
57
+ `invoke(d, g)` or `d.generate_random(s, g)`, if such an expression is
58
+ well-formed for a value `N` and an object `s` of type
59
+ `span<invoke_result_t<D&, G&>, N>`. \[*Note 2*: Values of N can differ
60
+ between invocations. — *end note*]
61
+ - Otherwise, calls
62
+ ``` cpp
63
+ ranges::generate(std::forward<R>(r), [&d, &g] { return invoke(d, g); });
64
+ ```
65
+
66
+ *Returns:* `ranges::end(r)`.
67
+
68
+ *Remarks:* The effects of `generate_random(r, g, d)` shall be equivalent
69
+ to
70
+
71
+ ``` cpp
72
+ ranges::generate(std::forward<R>(r), [&d, &g] { return invoke(d, g); })
73
+ ```
74
+
75
+ [*Note 2*: This implies that `d.generate_random(a, g)` fills `a` with
76
+ the values with the same random distribution as produced by invocation
77
+ of `invoke(d, g)`. — *end note*]
78
+
79
+ ``` cpp
80
+ template<class G, class D, output_iterator<invoke_result_t<D&, G&>> O, sentinel_for<O> S>
81
+ requires invocable<D&, G&> && uniform_random_bit_generator<remove_cvref_t<G>> &&
82
+ is_arithmetic_v<invoke_result_t<D&, G&>>
83
+ constexpr O ranges::generate_random(O first, S last, G&& g, D&& d);
84
+ ```
85
+
86
+ *Effects:* Equivalent to:
87
+
88
+ ``` cpp
89
+ return generate_random(subrange<O, S>(std::move(first), last), g, d);
90
+ ```
91
+