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