tmp/tmp02zln8si/{from.md → to.md}
RENAMED
|
@@ -29,11 +29,11 @@ namespace std {
|
|
| 29 |
: incrementable_traits<I> { };
|
| 30 |
|
| 31 |
template<class T>
|
| 32 |
requires requires { typename T::difference_type; }
|
| 33 |
struct incrementable_traits<T> {
|
| 34 |
-
using difference_type =
|
| 35 |
};
|
| 36 |
|
| 37 |
template<class T>
|
| 38 |
requires (!requires { typename T::difference_type; } &&
|
| 39 |
requires(const T& a, const T& b) { { a - b } -> integral; })
|
|
@@ -234,27 +234,27 @@ The members of a specialization `iterator_traits<I>` generated from the
|
|
| 234 |
|
| 235 |
- If `I` has valid [[temp.deduct]] member types `difference_type`,
|
| 236 |
`value_type`, `reference`, and `iterator_category`, then
|
| 237 |
`iterator_traits<I>` has the following publicly accessible members:
|
| 238 |
``` cpp
|
| 239 |
-
using iterator_category =
|
| 240 |
-
using value_type =
|
| 241 |
-
using difference_type =
|
| 242 |
using pointer = see below;
|
| 243 |
-
using reference =
|
| 244 |
```
|
| 245 |
|
| 246 |
If the *qualified-id* `I::pointer` is valid and denotes a type, then
|
| 247 |
`iterator_traits<I>::pointer` names that type; otherwise, it names
|
| 248 |
`void`.
|
| 249 |
- Otherwise, if `I` satisfies the exposition-only concept
|
| 250 |
`cpp17-input-iterator`, `iterator_traits<I>` has the following
|
| 251 |
publicly accessible members:
|
| 252 |
``` cpp
|
| 253 |
using iterator_category = see below;
|
| 254 |
-
using value_type =
|
| 255 |
-
using difference_type =
|
| 256 |
using pointer = see below;
|
| 257 |
using reference = see below;
|
| 258 |
```
|
| 259 |
|
| 260 |
- If the *qualified-id* `I::pointer` is valid and denotes a type,
|
|
@@ -324,16 +324,14 @@ To implement a generic `reverse` function, a C++ program can do the
|
|
| 324 |
following:
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
template<class BI>
|
| 328 |
void reverse(BI first, BI last) {
|
| 329 |
-
typename iterator_traits<BI>::difference_type n =
|
| 330 |
-
distance(first, last);
|
| 331 |
--n;
|
| 332 |
while (n > 0) {
|
| 333 |
-
typename iterator_traits<BI>::value_type
|
| 334 |
-
tmp = *first;
|
| 335 |
*first++ = *--last;
|
| 336 |
*last = tmp;
|
| 337 |
n -= 2;
|
| 338 |
}
|
| 339 |
}
|
|
|
|
| 29 |
: incrementable_traits<I> { };
|
| 30 |
|
| 31 |
template<class T>
|
| 32 |
requires requires { typename T::difference_type; }
|
| 33 |
struct incrementable_traits<T> {
|
| 34 |
+
using difference_type = T::difference_type;
|
| 35 |
};
|
| 36 |
|
| 37 |
template<class T>
|
| 38 |
requires (!requires { typename T::difference_type; } &&
|
| 39 |
requires(const T& a, const T& b) { { a - b } -> integral; })
|
|
|
|
| 234 |
|
| 235 |
- If `I` has valid [[temp.deduct]] member types `difference_type`,
|
| 236 |
`value_type`, `reference`, and `iterator_category`, then
|
| 237 |
`iterator_traits<I>` has the following publicly accessible members:
|
| 238 |
``` cpp
|
| 239 |
+
using iterator_category = I::iterator_category;
|
| 240 |
+
using value_type = I::value_type;
|
| 241 |
+
using difference_type = I::difference_type;
|
| 242 |
using pointer = see below;
|
| 243 |
+
using reference = I::reference;
|
| 244 |
```
|
| 245 |
|
| 246 |
If the *qualified-id* `I::pointer` is valid and denotes a type, then
|
| 247 |
`iterator_traits<I>::pointer` names that type; otherwise, it names
|
| 248 |
`void`.
|
| 249 |
- Otherwise, if `I` satisfies the exposition-only concept
|
| 250 |
`cpp17-input-iterator`, `iterator_traits<I>` has the following
|
| 251 |
publicly accessible members:
|
| 252 |
``` cpp
|
| 253 |
using iterator_category = see below;
|
| 254 |
+
using value_type = indirectly_readable_traits<I>::value_type;
|
| 255 |
+
using difference_type = incrementable_traits<I>::difference_type;
|
| 256 |
using pointer = see below;
|
| 257 |
using reference = see below;
|
| 258 |
```
|
| 259 |
|
| 260 |
- If the *qualified-id* `I::pointer` is valid and denotes a type,
|
|
|
|
| 324 |
following:
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
template<class BI>
|
| 328 |
void reverse(BI first, BI last) {
|
| 329 |
+
typename iterator_traits<BI>::difference_type n = distance(first, last);
|
|
|
|
| 330 |
--n;
|
| 331 |
while (n > 0) {
|
| 332 |
+
typename iterator_traits<BI>::value_type tmp = *first;
|
|
|
|
| 333 |
*first++ = *--last;
|
| 334 |
*last = tmp;
|
| 335 |
n -= 2;
|
| 336 |
}
|
| 337 |
}
|