Created on 2021-05-12.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [ranges.syn], header <ranges> synopsis, as indicated:
[…] namespace std::ranges { […] // [range.dangling], dangling iterator handling struct dangling; template<range R> using borrowed_iterator_t = see belowconditional_t<borrowed_range<R>, iterator_t<R>, dangling>; template<range R> using borrowed_subrange_t = see belowconditional_t<borrowed_range<R>, subrange<iterator_t<R>>, dangling>; […] }
Modify [range.dangling] as indicated:
-1- The tag type dangling is used together with the template aliases borrowed_iterator_t and borrowed_subrange_t. When an algorithm that typically returns an iterator into, or a subrange of, a range argument is called with an rvalue range argument that does not model borrowed_range ([range.range]), the return value possibly refers to a range whose lifetime has ended. In such cases, the tag type dangling is returned instead of an iterator or subrange.
namespace std::ranges { struct dangling { […] }; }-2- [Example 1: […] — end example]
-?- For a type R that models range:
(?.1) — if R models borrowed_range, then borrowed_iterator_t<R> denotes iterator_t<R>, and borrowed_subrange_t<R> denotes subrange<iterator_t<R>>;
(?.2) — otherwise, both borrowed_iterator_t<R> and borrowed_subrange_t<R> denote dangling.
[ 2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-05-20; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
As discussed in P1715R0, there are ways to implement something equivalent to std::conditional_t that are better for compile times. However, borrowed_{iterator,subrange}_t are currently specified to use conditional_t, and this appears to be user-observable due to the transparency of alias templates. We should simply specify the desired result and leave the actual definition to the implementation.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-06-07 16:58:04 | admin | set | messages: + msg11913 |
2021-06-07 16:58:04 | admin | set | status: voting -> wp |
2021-05-26 21:11:22 | admin | set | status: ready -> voting |
2021-05-20 08:55:35 | admin | set | messages: + msg11829 |
2021-05-20 08:55:35 | admin | set | status: new -> ready |
2021-05-15 17:07:53 | admin | set | messages: + msg11801 |
2021-05-12 00:00:00 | admin | create |