Title
safe_range<SomeRange&> case
Status
c++23
Section
[range.range]
Submitter
Johel Ernesto Guerrero Peña

Created on 2019-12-19.00:00:00 last changed 12 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4885.

  1. Modify [range.range] as indicated:

    template<class T>
      concept borrowed_range =
        range<T> &&
          (is_lvalue_reference_v<T> || enable_borrowed_range<remove_cvref_t<T>>);
    

    -5- Let U be remove_reference_t<T> if T is an rvalue reference type, and T otherwise. Given an expression E such that decltype((E)) is T a variable u of type U, T models borrowed_range only if the validity of iterators obtained from the object denoted by E u is not tied to the lifetime of that object variable.

    -6- [Note: Since the validity of iterators is not tied to the lifetime of an objecta variable whose type models borrowed_range, a function can accept arguments of with a parameter of such a type by value and can return iterators obtained from it without danger of dangling. — end note]

Date: 2021-10-14.00:00:00

[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]

Date: 2021-09-15.00:00:00

[ 2021-09-20; Reflector poll ]

Set status to Tentatively Ready after five votes in favour during reflector poll in June.

Date: 2021-05-19.00:00:00

[ 2021-05-19 Tim updates wording ]

The new wording below attempts to keep the "borrowed" property generally applicable to all models of borrowed_range, instead of bluntly carving out lvalue reference types.

Date: 2021-05-20.01:13:33

[ 2020-01 Priority set to 3 after review on the reflector. ]

Previous resolution [SUPERSEDED]:

This wording is relative to N4842.

  1. Modify [range.range] as indicated:

    template<class T>
      concept safe_range =
        range<T> &&
          (is_lvalue_reference_v<T> || enable_safe_range<remove_cvref_t<T>>);
    

    -5- Given an expression E such that decltype((E)) is T,A type T models safe_range only if:

    1. (5.1) — is_lvalue_reference_v<T> is true, or

    2. (5.2) — given an expression E such that decltype((E)) is T, if the validity of iterators obtained from the object denoted by E is not tied to the lifetime of that object.

    -6- [Note: Since the validity of iterators is not tied to the lifetime of an object whose type models safe_range, aA function can accept arguments of such a type that models safe_range by value and return iterators obtained from it without danger of dangling. — end note]

Date: 2019-12-19.00:00:00

[range.dangling] p2 hints at how safe_range should allow lvalue ranges to model it. However, its wording doesn't take into account that case.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12115
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-09-20 11:34:46adminsetmessages: + msg12057
2021-09-20 11:34:46adminsetstatus: new -> ready
2021-05-20 01:13:33adminsetmessages: + msg11821
2020-01-05 16:13:01adminsetmessages: + msg10911
2019-12-21 15:01:34adminsetmessages: + msg10901
2019-12-19 00:00:00admincreate