tmp/tmp846psjd3/{from.md → to.md}
RENAMED
|
@@ -3,23 +3,26 @@
|
|
| 3 |
It is often desirable for a function template specialization to find out
|
| 4 |
what is the most specific category of its iterator argument, so that the
|
| 5 |
function can select the most efficient algorithm at compile time. To
|
| 6 |
facilitate this, the library introduces *category tag* classes which are
|
| 7 |
used as compile time tags for algorithm selection. They are:
|
| 8 |
-
`
|
| 9 |
-
`bidirectional_iterator_tag`
|
| 10 |
-
iterator of type `
|
| 11 |
-
`iterator_traits<
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
namespace std {
|
| 16 |
-
struct input_iterator_tag { };
|
| 17 |
struct output_iterator_tag { };
|
|
|
|
| 18 |
struct forward_iterator_tag: public input_iterator_tag { };
|
| 19 |
struct bidirectional_iterator_tag: public forward_iterator_tag { };
|
| 20 |
struct random_access_iterator_tag: public bidirectional_iterator_tag { };
|
|
|
|
| 21 |
}
|
| 22 |
```
|
| 23 |
|
| 24 |
[*Example 1*:
|
| 25 |
|
|
@@ -39,11 +42,11 @@ template<class T> struct iterator_traits<BinaryTreeIterator<T>> {
|
|
| 39 |
|
| 40 |
— *end example*]
|
| 41 |
|
| 42 |
[*Example 2*:
|
| 43 |
|
| 44 |
-
If `evolve()` is well
|
| 45 |
implemented more efficiently for random access iterators, then the
|
| 46 |
implementation is as follows:
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
template<class BidirectionalIterator>
|
|
|
|
| 3 |
It is often desirable for a function template specialization to find out
|
| 4 |
what is the most specific category of its iterator argument, so that the
|
| 5 |
function can select the most efficient algorithm at compile time. To
|
| 6 |
facilitate this, the library introduces *category tag* classes which are
|
| 7 |
used as compile time tags for algorithm selection. They are:
|
| 8 |
+
`output_iterator_tag`, `input_iterator_tag`, `forward_iterator_tag`,
|
| 9 |
+
`bidirectional_iterator_tag`, `random_access_iterator_tag`, and
|
| 10 |
+
`contiguous_iterator_tag`. For every iterator of type `I`,
|
| 11 |
+
`iterator_traits<I>::iterator_category` shall be defined to be a
|
| 12 |
+
category tag that describes the iterator’s behavior. Additionally,
|
| 13 |
+
`iterator_traits<I>::iterator_concept` may be used to indicate
|
| 14 |
+
conformance to the iterator concepts [[iterator.concepts]].
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
namespace std {
|
|
|
|
| 18 |
struct output_iterator_tag { };
|
| 19 |
+
struct input_iterator_tag { };
|
| 20 |
struct forward_iterator_tag: public input_iterator_tag { };
|
| 21 |
struct bidirectional_iterator_tag: public forward_iterator_tag { };
|
| 22 |
struct random_access_iterator_tag: public bidirectional_iterator_tag { };
|
| 23 |
+
struct contiguous_iterator_tag: public random_access_iterator_tag { };
|
| 24 |
}
|
| 25 |
```
|
| 26 |
|
| 27 |
[*Example 1*:
|
| 28 |
|
|
|
|
| 42 |
|
| 43 |
— *end example*]
|
| 44 |
|
| 45 |
[*Example 2*:
|
| 46 |
|
| 47 |
+
If `evolve()` is well-defined for bidirectional iterators, but can be
|
| 48 |
implemented more efficiently for random access iterators, then the
|
| 49 |
implementation is as follows:
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
template<class BidirectionalIterator>
|