From Jason Turner

[range.range]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6jqgtbq2/{from.md → to.md} +13 -13
tmp/tmp6jqgtbq2/{from.md → to.md} RENAMED
@@ -26,37 +26,37 @@ Given an expression `t` such that `decltype((t))` is `T&`, `T` models
26
  time and non-modifying, and
27
  - if the type of `ranges::begin(t)` models `forward_iterator`,
28
  `ranges::begin(t)` is equality-preserving.
29
 
30
  [*Note 1*: Equality preservation of both `ranges::begin` and
31
- `ranges::end` enables passing a `range` whose iterator type models
32
  `forward_iterator` to multiple algorithms and making multiple passes
33
  over the range by repeated calls to `ranges::begin` and `ranges::end`.
34
  Since `ranges::begin` is not required to be equality-preserving when the
35
- return type does not model `forward_iterator`, repeated calls might not
36
- return equal values or might not be well-defined; `ranges::begin` should
37
- be called at most once for such a range. — *end note*]
38
 
39
  ``` cpp
40
  template<class T>
41
  concept borrowed_range =
42
- range<T> &&
43
- (is_lvalue_reference_v<T> || enable_borrowed_range<remove_cvref_t<T>>);
44
  ```
45
 
46
- Given an expression `E` such that `decltype((E))` is `T`, `T` models
47
- `borrowed_range` only if the validity of iterators obtained from the
48
- object denoted by `E` is not tied to the lifetime of that object.
 
49
 
50
  [*Note 2*: Since the validity of iterators is not tied to the lifetime
51
- of an object whose type models `borrowed_range`, a function can accept
52
- arguments of such a type by value and return iterators obtained from it
53
- without danger of dangling. — *end note*]
54
 
55
  ``` cpp
56
  template<class>
57
- inline constexpr bool enable_borrowed_range = false;
58
  ```
59
 
60
  *Remarks:* Pursuant to [[namespace.std]], users may specialize
61
  `enable_borrowed_range` for cv-unqualified program-defined types. Such
62
  specializations shall be usable in constant expressions [[expr.const]]
 
26
  time and non-modifying, and
27
  - if the type of `ranges::begin(t)` models `forward_iterator`,
28
  `ranges::begin(t)` is equality-preserving.
29
 
30
  [*Note 1*: Equality preservation of both `ranges::begin` and
31
+ `ranges::end` enables passing a range whose iterator type models
32
  `forward_iterator` to multiple algorithms and making multiple passes
33
  over the range by repeated calls to `ranges::begin` and `ranges::end`.
34
  Since `ranges::begin` is not required to be equality-preserving when the
35
+ return type does not model `forward_iterator`, it is possible for
36
+ repeated calls to not return equal values or to not be
37
+ well-defined. — *end note*]
38
 
39
  ``` cpp
40
  template<class T>
41
  concept borrowed_range =
42
+ range<T> && (is_lvalue_reference_v<T> || enable_borrowed_range<remove_cvref_t<T>>);
 
43
  ```
44
 
45
+ Let `U` be `remove_reference_t<T>` if `T` is an rvalue reference type,
46
+ and `T` otherwise. Given a variable `u` of type `U`, `T` models
47
+ `borrowed_range` only if the validity of iterators obtained from `u` is
48
+ not tied to the lifetime of that variable.
49
 
50
  [*Note 2*: Since the validity of iterators is not tied to the lifetime
51
+ of a variable whose type models `borrowed_range`, a function with a
52
+ parameter of such a type can return iterators obtained from it without
53
+ danger of dangling. — *end note*]
54
 
55
  ``` cpp
56
  template<class>
57
+ constexpr bool enable_borrowed_range = false;
58
  ```
59
 
60
  *Remarks:* Pursuant to [[namespace.std]], users may specialize
61
  `enable_borrowed_range` for cv-unqualified program-defined types. Such
62
  specializations shall be usable in constant expressions [[expr.const]]