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
|
| 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`,
|
| 36 |
-
return equal values or
|
| 37 |
-
|
| 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 |
-
|
| 47 |
-
`
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
[*Note 2*: Since the validity of iterators is not tied to the lifetime
|
| 51 |
-
of
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
template<class>
|
| 57 |
-
|
| 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]]
|