📄 iter-issue-list.rst
字号:
X1 = random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag)
X1 = bidirectional_iterator_tag
else
X1 = forward_iterator_tag
}
else
{
if (C is convertible to single_pass_traversal_tag
&& R is convertible to V)
X1 = input_iterator_tag
else
X1 = C
}
2. |category-to-traversal|_\ (X) is convertible to the most
derived traversal tag type to which X is also
convertible, and not to any more-derived traversal tag
type.
.. |category-to-traversal| replace:: *category-to-traversal*
.. |iterator-category| replace:: *iterator-category*
.. _iterator-category:
In [lib.iterator.facade] ``iterator_facade`` requirements:
Remove:
``AccessCategory`` must be an unsigned value which uses no more
bits than the greatest value of ``iterator_access``.
In the **Iterator Adaptor** section, change:
Several of the template parameters of ``iterator_adaptor`` default
to ``use_default`` (or ``use_default_access``).
to:
Several of the template parameters of ``iterator_adaptor`` default
to ``use_default``.
In [lib.iterator.special.adaptors]:
Change::
template <
class Iterator
, class Value = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
class indirect_iterator
to::
template <
class Iterator
, class Value = use_default
, class CategoryOrTraversal = use_default
, class Reference = use_default
, class Difference = use_default
>
class indirect_iterator
Change::
template <
class Iterator2, class Value2, unsigned Access2, class Traversal2
, class Reference2, class Difference2
>
indirect_iterator(
to::
template <
class Iterator2, class Value2, class Category2
, class Reference2, class Difference2
>
indirect_iterator(
Change::
template <
class Incrementable
, unsigned Access = use_default_access
, class Traversal = use_default
, class Difference = use_default
>
class counting_iterator
to::
template <
class Incrementable
, class CategoryOrTraversal = use_default
, class Difference = use_default
>
class counting_iterator
Change::
typedef iterator_tag<
writable_iterator
, incrementable_traversal_tag
> iterator_category;
to:
typedef std::output_iterator_tag iterator_category;
In [lib.iterator.adaptor]
Change::
template <
class Derived
, class Base
, class Value = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
class iterator_adaptor
To::
template <
class Derived
, class Base
, class Value = use_default
, class CategoryOrTraversal = use_default
, class Reference = use_default
, class Difference = use_default
>
class iterator_adaptor
:Rationale:
1. There are two reasons for removing ``is_writable``
and ``is_swappable``. The first is that we do not know of
a way to fix the specification so that it gives the correct
answer for all iterators. Second, there was only a weak
motivation for having ``is_writable`` and ``is_swappable``
there in the first place. The main motivation was simply
uniformity: we have tags for the old iterator categories
so we should have tags for the new iterator categories.
While having tags and the capability to dispatch based
on the traversal categories is often used, we see
less of a need for dispatching based on writability
and swappability, since typically algorithms
that need these capabilities have no alternative if
they are not provided.
2. We discovered that the ``is_readable`` trait can be implemented
using only the iterator type itself and its ``value_type``.
Therefore we remove the requirement for ``is_readable`` from the
Readable Iterator concept, and change the definition of
``is_readable`` so that it works for any iterator type.
3. The purpose of the ``iterator_tag`` class was to bundle the
traversal and access category tags into the
``iterator_category`` typedef. With ``is_writable`` and
``is_swappable`` gone, and ``is_readable`` no longer in need of
special hints, there is no reason for iterators to provide
information about the access capabilities of an iterator. Thus
there is no need for the ``iterator_tag``. The traversal tag can
be directly used for the ``iterator_category``. If a new
iterator is intended to be backward compatible with old iterator
concepts, a tag type that is convertible to both one of the new
traversal tags and also to an old iterator tag can be created
and use for the ``iterator_category``.
4. The changes to the specification of ``traversal_category`` are a
direct result of the removal of ``iterator_tag``.
9.16 is_writable_iterator returns false positives
=================================================
:Submitter: Dave Abrahams
:Status: New
is_writable_iterator returns false positives for forward iterators
whose value_type has a private assignment operator, or whose
reference type is not a reference (currently legal).
:Proposed Resolution: See the resolution to 9.15.
9.17 is_swappable_iterator returns false positives
==================================================
:Submitter: Dave Abrahams
:Status: New
is_swappable_iterator has the same problems as
is_writable_iterator. In addition, if we allow users to write their
own iter_swap functions it's easy to imagine old-style iterators
for which is_swappable returns false negatives.
:Proposed Resolution: See the resolution to 9.15.
9.18 Are is_readable, is_writable, and is_swappable useful?
===========================================================
:Submitter: Dave Abrahams
:Status: New
I am concerned that there is little use for any of is_readable,
is_writable, or is_swappable, and that not only do they unduly
constrain iterator implementors but they add overhead to
iterator_facade and iterator_adaptor in the form of a template
parameter which would otherwise be unneeded. Since we can't
implement two of them accurately for old-style iterators, I am
having a hard time justifying their impact on the rest of the
proposal(s).
:Proposed Resolution: See the resolution to 9.15.
9.19 Non-Uniformity of the "lvalue_iterator Bit"
================================================
:Submitter: Dave Abrahams
:Status: New
The proposed iterator_tag class template accepts an "access bits"
parameter which includes a bit to indicate the iterator's
lvalueness (whether its dereference operator returns a reference to
its value_type. The relevant part of N1550 says:
The purpose of the lvalue_iterator part of the iterator_access
enum is to communicate to iterator_tagwhether the reference type
is an lvalue so that the appropriate old category can be chosen
for the base class. The lvalue_iterator bit is not recorded in
the iterator_tag::access data member.
The lvalue_iterator bit is not recorded because N1550 aims to
improve orthogonality of the iterator concepts, and a new-style
iterator's lvalueness is detectable by examining its reference
type. This inside/outside difference is awkward and confusing.
:Proposed Resolution: The iterator_tag class will be removed, so this is no longer an issue.
See the resolution to 9.15.
9.20 Traversal Concepts and Tags
================================
:Submitter: Dave Abrahams
:Status: New
Howard Hinnant pointed out some inconsistencies with the naming of
these tag types::
incrementable_iterator_tag // ++r, r++
single_pass_iterator_tag // adds a == b, a != b
forward_traversal_iterator_tag // adds multi-pass
bidirectional_traversal_iterator_tag // adds --r, r--
random_access_traversal_iterator_tag // adds r+n,n+r,etc.
Howard thought that it might be better if all tag names contained
the word "traversal". It's not clear that would result in the best
possible names, though. For example, incrementable iterators can
only make a single pass over their input. What really distinguishes
single pass iterators from incrementable iterators is not that they
can make a single pass, but that they are equality
comparable. Forward traversal iterators really distinguish
themselves by introducing multi-pass capability. Without entering
a "Parkinson's Bicycle Shed" type of discussion, it might be worth
giving the names of these tags (and the associated concepts) some
extra attention.
:Proposed resolution: Change the names of the traversal tags to the
following names::
incrementable_traversal_tag
single_pass_traversal_tag
forward_traversal_tag
bidirectional_traversal_tag
random_access_traversal_tag
In [lib.iterator.traversal]:
Change:
+--------------------------------+-------------------------------+--------------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``incrementable_iterator_tag`` | |
+--------------------------------+-------------------------------+--------------------+
to:
+--------------------------------+-------------------------------+--------------------+
|``iterator_traversal<X>::type`` |Convertible to | |
| |``incrementable_traversal_tag``| |
+--------------------------------+-------------------------------+--------------------+
Change:
+--------------------------------+-----------------------------+---------------------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``single_pass_iterator_tag`` | |
+--------------------------------+-----------------------------+---------------------------+
to:
+--------------------------------+-----------------------------+---------------------------+
|``iterator_traversal<X>::type`` |Convertible to | |
| |``single_pass_traversal_tag``| |
+--------------------------------+-----------------------------+---------------------------+
Change:
+---------------------------------------+-----------------------------------+---------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``forward_traversal_iterator_tag`` | |
+---------------------------------------+-----------------------------------+---------------+
to:
+---------------------------------------+-----------------------------------+----------------------------+
|``iterator_traversal<X>::type`` |Convertible to | |
| |``forward_traversal_tag`` | |
+---------------------------------------+-----------------------------------+----------------------------+
Change:
+------------------------------------+---------------------------------------------+---------------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``bidirectional_traversal_iterator_tag`` | |
+------------------------------------+---------------------------------------------+---------------------+
to:
+--------------------------------+-------------------------------+---------------------+
|``iterator_traversal<X>::type`` |Convertible to | |
| |``bidirectional_traversal_tag``| |
+--------------------------------+-------------------------------+---------------------+
Change:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -