ref_problem.rst
来自「Boost provides free peer-reviewed portab」· RST 代码 · 共 64 行
RST
64 行
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Problem with ``reference`` and old/new iterator category correspondance++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.. _N1550: http://www.boost-consulting.com/writing/n1550.html.. _N1530: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html:Author: David Abrahams and Jeremy Siek:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu:Organization: `Boost Consulting`_, Indiana University Bloomington:date: $Date: 2003-11-17 11:52:29 -0500 (Mon, 17 Nov 2003) $:Copyright: Copyright David Abrahams, Jeremy Siek 2003. Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).. _`Boost Consulting`: http://www.boost-consulting.com============== Introduction==============The new iterator categories are intended to correspond to the olditerator categories, as specified in a diagram in N1550_. For example,an iterator categorized as a mutable Forward Iterator under the oldscheme is now a Writable, Lvalue, and Foward Traversal iterator.However, there is a problem with this correspondance, the new iteratorcategories place requirements on the ``iterator_traits<X>::reference``type whereas the standard iterator requirements say nothing about the``reference`` type . In particular, the new Readable Iteratorrequirements say that the return type of ``*a`` must be``iterator_traits<X>::reference`` and the Lvalue Iterator requirementssays that ``iterator_traits<X>::reference`` must be ``T&`` or ``constT&``.==================== Proposed Resolution====================Change the standard requirements to match the requirements of the newiterators. (more details to come)========== Rationale==========The lack of specification in the standard of the ``reference`` type iscertainly a defect. Without specification, it is entirely useless in ageneric function. The current practice in the community is generallyto assume there are requirements on the ``reference`` type, such asthose proposed in the new iterator categories.There is some danger in *adding* requirements to existing concepts.This will mean that some existing iterator types will no longer meetthe iterator requirements. However, we feel that the impact of this issmall enough to warrant going ahead with this change.An alternative solution would be to leave the standard requirements asis, and to remove the requirements for the ``reference`` type in thenew iterator concepts. We are not in favor of this approach because itextends what we see as a defect further into the future.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?