Created on 2022-08-26.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to the forthcoming C++23 CD.
Modify [range.adaptor.tuple] as indicated:
template<class F, class Tuple> constexpr auto tuple-for-each(F&& f, Tuple&& t) { // exposition only apply([&]<class... Ts>(Ts&&... elements) { (static_cast<void>(invoke(f, std::forward<Ts>(elements))), ...); }, std::forward<Tuple>(t)); }
[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]
[ 2022-09-23; Reflector poll ]
Set status to Tentatively Ready after nine votes in favour during reflector poll.
Feedback from reviewers:
"NAD. This exposition-only facility is only used with things that return void. As far as I know, users can't define operator, for void." "If I see the void cast, I don't need to audit the uses or be concerned that we'll add a broken use in the future."
The specification for tuple-for-each is:
template<class F, class Tuple> constexpr auto tuple-for-each(F&& f, Tuple&& t) { // exposition only apply([&]<class... Ts>(Ts&&... elements) { (invoke(f, std::forward<Ts>(elements)), ...); }, std::forward<Tuple>(t)); }
Given
struct Evil { void operator,(Evil) { abort(); } };
and tuple<int, int> t, then tuple-for-each([](int) { return Evil{}; }, t), the program will (unintentionally) abort.
It seems likely that our Evil's operator, should not be called.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2022-11-17 00:42:33 | admin | set | messages: + msg13064 |
2022-11-17 00:42:33 | admin | set | status: voting -> wp |
2022-11-08 03:46:49 | admin | set | status: ready -> voting |
2022-09-23 14:50:50 | admin | set | messages: + msg12783 |
2022-09-23 14:50:50 | admin | set | status: new -> ready |
2022-08-26 20:00:23 | admin | set | messages: + msg12720 |
2022-08-26 00:00:00 | admin | create |