tmp/tmpxe4zib7o/{from.md → to.md}
RENAMED
|
@@ -35,15 +35,15 @@ The definitions in this subclause make use of the following
|
|
| 35 |
exposition-only concepts:
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
template<class I>
|
| 39 |
concept cpp17-iterator =
|
| 40 |
-
|
| 41 |
{ *i } -> can-reference;
|
| 42 |
{ ++i } -> same_as<I&>;
|
| 43 |
{ *i++ } -> can-reference;
|
| 44 |
-
};
|
| 45 |
|
| 46 |
template<class I>
|
| 47 |
concept cpp17-input-iterator =
|
| 48 |
cpp17-iterator<I> && equality_comparable<I> && requires(I i) {
|
| 49 |
typename incrementable_traits<I>::difference_type;
|
|
@@ -56,11 +56,11 @@ concept cpp17-input-iterator =
|
|
| 56 |
};
|
| 57 |
|
| 58 |
template<class I>
|
| 59 |
concept cpp17-forward-iterator =
|
| 60 |
cpp17-input-iterator<I> && constructible_from<I> &&
|
| 61 |
-
|
| 62 |
same_as<remove_cvref_t<iter_reference_t<I>>,
|
| 63 |
typename indirectly_readable_traits<I>::value_type> &&
|
| 64 |
requires(I i) {
|
| 65 |
{ i++ } -> convertible_to<const I&>;
|
| 66 |
{ *i++ } -> same_as<iter_reference_t<I>>;
|
|
@@ -152,10 +152,16 @@ The members of a specialization `iterator_traits<I>` generated from the
|
|
| 152 |
|
| 153 |
Explicit or partial specializations of `iterator_traits` may have a
|
| 154 |
member type `iterator_concept` that is used to indicate conformance to
|
| 155 |
the iterator concepts [[iterator.concepts]].
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
`iterator_traits` is specialized for pointers as
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
namespace std {
|
| 161 |
template<class T>
|
|
@@ -169,11 +175,11 @@ namespace std {
|
|
| 169 |
using reference = T&;
|
| 170 |
};
|
| 171 |
}
|
| 172 |
```
|
| 173 |
|
| 174 |
-
[*Example
|
| 175 |
|
| 176 |
To implement a generic `reverse` function, a C++ program can do the
|
| 177 |
following:
|
| 178 |
|
| 179 |
``` cpp
|
|
|
|
| 35 |
exposition-only concepts:
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
template<class I>
|
| 39 |
concept cpp17-iterator =
|
| 40 |
+
requires(I i) {
|
| 41 |
{ *i } -> can-reference;
|
| 42 |
{ ++i } -> same_as<I&>;
|
| 43 |
{ *i++ } -> can-reference;
|
| 44 |
+
} && copyable<I>;
|
| 45 |
|
| 46 |
template<class I>
|
| 47 |
concept cpp17-input-iterator =
|
| 48 |
cpp17-iterator<I> && equality_comparable<I> && requires(I i) {
|
| 49 |
typename incrementable_traits<I>::difference_type;
|
|
|
|
| 56 |
};
|
| 57 |
|
| 58 |
template<class I>
|
| 59 |
concept cpp17-forward-iterator =
|
| 60 |
cpp17-input-iterator<I> && constructible_from<I> &&
|
| 61 |
+
is_reference_v<iter_reference_t<I>> &&
|
| 62 |
same_as<remove_cvref_t<iter_reference_t<I>>,
|
| 63 |
typename indirectly_readable_traits<I>::value_type> &&
|
| 64 |
requires(I i) {
|
| 65 |
{ i++ } -> convertible_to<const I&>;
|
| 66 |
{ *i++ } -> same_as<iter_reference_t<I>>;
|
|
|
|
| 152 |
|
| 153 |
Explicit or partial specializations of `iterator_traits` may have a
|
| 154 |
member type `iterator_concept` that is used to indicate conformance to
|
| 155 |
the iterator concepts [[iterator.concepts]].
|
| 156 |
|
| 157 |
+
[*Example 1*: To indicate conformance to the `input_iterator` concept
|
| 158 |
+
but a lack of conformance to the *Cpp17InputIterator* requirements
|
| 159 |
+
[[input.iterators]], an `iterator_traits` specialization might have
|
| 160 |
+
`iterator_concept` denote `input_iterator_tag` but not define
|
| 161 |
+
`iterator_category`. — *end example*]
|
| 162 |
+
|
| 163 |
`iterator_traits` is specialized for pointers as
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
namespace std {
|
| 167 |
template<class T>
|
|
|
|
| 175 |
using reference = T&;
|
| 176 |
};
|
| 177 |
}
|
| 178 |
```
|
| 179 |
|
| 180 |
+
[*Example 2*:
|
| 181 |
|
| 182 |
To implement a generic `reverse` function, a C++ program can do the
|
| 183 |
following:
|
| 184 |
|
| 185 |
``` cpp
|