Created on 2024-04-28.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N4981.
Modify [rand.synopsis], header <random> synopsis, as indicated:
#include <initializer_list> // see [initializer.list.syn]
namespace std {
[…]
namespace ranges {
[…]
template<class R, class G, class D>
requires output_range<R, invoke_result_t<D&, G&>> && invocable<D&, G&> &&
uniform_random_bit_generator<remove_cvref_t<G>> &&
is_arithmetic_v<invoke_result_t<D&, G&>>
constexpr borrowed_iterator_t<R> generate_random(R&& r, G&& g, D&& d);
template<class G, class D, output_iterator<invoke_result_t<D&, G&>> O, sentinel_for<O> S>
requires invocable<D&, G&> && uniform_random_bit_generator<remove_cvref_t<G>> &&
is_arithmetic_v<invoke_result_t<D&, G&>>
constexpr O generate_random(O first, S last, G&& g, D&& d);
}
[…]
}
Modify [alg.rand.generate] as indicated:
template<class R, class G, class D> requires output_range<R, invoke_result_t<D&, G&>> && invocable<D&, G&> && uniform_random_bit_generator<remove_cvref_t<G>> && is_arithmetic_v<invoke_result_t<D&, G&>> constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g, D&& d);-5- Effects:
[…]template<class G, class D, output_iterator<invoke_result_t<D&, G&>> O, sentinel_for<O> S> requires invocable<D&, G&> && uniform_random_bit_generator<remove_cvref_t<G>> && is_arithmetic_v<invoke_result_t<D&, G&>> constexpr O ranges::generate_random(O first, S last, G&& g, D&& d);-8- Effects: Equivalent to:
[…]
[ Wrocław 2024-11-23; Status changed: Voting → WP. ]
[ 2024-10-09; LWG telecon: Move to Ready ]
[ 2024-08-02; Reflector poll ]
Set priority to 2 after reflector poll.
[ 2024-05-12, Hewill Kang provides improved wording ]
The non-specialized case of generate_random(r, g, d) would call ranges::generate(r, [&d, &g] { return invoke(d, g); }). However, the lambda does not explicitly specify the return type, which leads to a hard error when invoke returns a reference to the object that is not copyable or R is not the output_range for decay_t<invoke_result_t<D&, G&>>.
This wording is relative to N4981.
Modify [alg.rand.generate] as indicated:
template<class R, class G, class D> requires output_range<R, invoke_result_t<D&, G&>> && invocable<D&, G&> && uniform_random_bit_generator<remove_cvref_t<G>> constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g, D&& d);-5- Effects:
(5.1) — […]
(5.2) — […]
(5.3) — Otherwise, calls:
ranges::generate(std::forward<R>(r), [&d, &g] -> decltype(auto) { return invoke(d, g); });-6- Returns: ranges::end(r)
-7- Remarks: The effects of generate_random(r, g, d) shall be equivalent to
ranges::generate(std::forward<R>(r), [&d, &g] -> decltype(auto) { return invoke(d, g); })
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-11-28 21:40:31 | admin | set | messages: + msg14480 |
2024-11-28 21:40:31 | admin | set | status: voting -> wp |
2024-11-19 16:09:07 | admin | set | status: ready -> voting |
2024-10-09 16:52:10 | admin | set | messages: + msg14434 |
2024-10-09 16:52:10 | admin | set | status: new -> ready |
2024-08-02 21:52:03 | admin | set | messages: + msg14288 |
2024-05-12 12:22:51 | admin | set | messages: + msg14139 |
2024-05-04 13:08:33 | admin | set | messages: + msg14093 |
2024-04-28 00:00:00 | admin | create |