You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given an expression E such that decltype((E)) is T, T models safe_range only if the validity of iterators obtained from the object denoted by E is not tied to the lifetime of that object.
[ Note: Since the validity of iterators is not tied to the lifetime of an object whose type models safe_range, a function can accept arguments of such a type by value and return iterators obtained from it without danger of dangling. — end note ]
Given std::vector<int> x{1, 2, 3};, if E is x, its type std::vector<int>& models safe_range, but the validity of the iterators obtained from the object it denotes are tied to its lifetime.
The text was updated successfully, but these errors were encountered:
This is actually normative. As such, std::vector<int>& can't model safe_range because the iterators of x are tied to the lifetime of the object it denotes. The intention is to actually allow such a case, given its use throughout [range.subrange] and in [range.dangling]#2.
jensmaurer
changed the title
[range.range] Misleading description of safe_range
[range.range] LWG 3361: Misleading description of safe_range
Dec 21, 2019
From http://eel.is/c++draft/range.range#itemdecl:2:
Given
std::vector<int> x{1, 2, 3};
, ifE
isx
, its typestd::vector<int>&
modelssafe_range
, but the validity of the iterators obtained from the object it denotes are tied to its lifetime.The text was updated successfully, but these errors were encountered: