2004-01-27 17:03:46 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
2007-06-07 20:53:46 +00:00
< meta name = "generator" content = "Docutils 0.3.6: http://docutils.sourceforge.net/" />
2004-01-27 17:03:46 +00:00
< title > Problem with reference and old/new iterator category correspondance</ title >
2007-06-07 20:53:46 +00:00
< link rel = "stylesheet" href = "default.css" type = "text/css" />
2004-01-27 17:03:46 +00:00
</ head >
< body >
2007-06-07 20:53:46 +00:00
< h1 class = "title" > Problem with < tt class = "literal" >< span class = "pre" > reference</ span ></ tt > and old/new iterator category correspondance</ h1 >
2004-11-02 14:31:27 +00:00
< div class = "document" id = "problem-with-reference-and-old-new-iterator-category-correspondance" >
2007-06-07 20:53:46 +00:00
< table class = "field-list" frame = "void" rules = "none" >
< col class = "field-name" />
< col class = "field-body" />
2004-01-27 17:03:46 +00:00
< tbody valign = "top" >
2007-06-07 20:53:46 +00:00
< tr class = "field" >< th class = "field-name" > Author:</ th >< td class = "field-body" > David Abrahams and Jeremy Siek</ td >
</ tr >
< tr class = "field" >< th class = "field-name" > Contact:</ th >< td class = "field-body" >< a class = "reference" href = "mailto:dave@boost-consulting.com" > dave@ boost-consulting.com</ a > , < a class = "reference" href = "mailto:jsiek@osl.iu.edu" > jsiek@ osl.iu.edu</ a ></ td >
</ tr >
< tr class = "field" >< th class = "field-name" > Organization:</ th >< td class = "field-body" >< a class = "reference" href = "http://www.boost-consulting.com" > Boost Consulting</ a > , Indiana University Bloomington</ td >
</ tr >
< tr class = "field" >< th class = "field-name" > date:</ th >< td class = "field-body" > $Date$</ td >
</ tr >
< tr class = "field" >< th class = "field-name" > Copyright:</ th >< td class = "field-body" > Copyright David Abrahams, Jeremy Siek 2003. Use, modification and
2004-01-27 17:03:46 +00:00
distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
2007-06-07 20:53:46 +00:00
at < a class = "reference" href = "http://www.boost.org/LICENSE_1_0.txt" > http://www.boost.org/LICENSE_1_0.txt</ a > )</ td >
</ tr >
2004-01-27 17:03:46 +00:00
</ tbody >
</ table >
2007-06-07 20:53:46 +00:00
< div class = "section" id = "introduction" >
< h1 >< a name = "introduction" > Introduction</ a ></ h1 >
2004-01-27 17:03:46 +00:00
< p > The new iterator categories are intended to correspond to the old
iterator categories, as specified in a diagram in < a class = "reference" href = "http://www.boost-consulting.com/writing/n1550.html" > N1550</ a > . For example,
an iterator categorized as a mutable Forward Iterator under the old
scheme is now a Writable, Lvalue, and Foward Traversal iterator.
However, there is a problem with this correspondance, the new iterator
2007-06-07 20:53:46 +00:00
categories place requirements on the < tt class = "literal" >< span class = "pre" > iterator_traits< X> ::reference</ span ></ tt >
2004-01-27 17:03:46 +00:00
type whereas the standard iterator requirements say nothing about the
2007-06-07 20:53:46 +00:00
< tt class = "literal" >< span class = "pre" > reference</ span ></ tt > type . In particular, the new Readable Iterator
requirements say that the return type of < tt class = "literal" >< span class = "pre" > *a</ span ></ tt > must be
< tt class = "literal" >< span class = "pre" > iterator_traits< X> ::reference</ span ></ tt > and the Lvalue Iterator requirements
says that < tt class = "literal" >< span class = "pre" > iterator_traits< X> ::reference</ span ></ tt > must be < tt class = "literal" >< span class = "pre" > T& </ span ></ tt > or < tt class = "literal" >< span class = "pre" > const</ span >
2004-01-27 17:03:46 +00:00
< span class = "pre" > T& </ span ></ tt > .</ p >
</ div >
2007-06-07 20:53:46 +00:00
< div class = "section" id = "proposed-resolution" >
< h1 >< a name = "proposed-resolution" > Proposed Resolution</ a ></ h1 >
2004-01-27 17:03:46 +00:00
< p > Change the standard requirements to match the requirements of the new
iterators. (more details to come)</ p >
</ div >
2007-06-07 20:53:46 +00:00
< div class = "section" id = "rationale" >
< h1 >< a name = "rationale" > Rationale</ a ></ h1 >
< p > The lack of specification in the standard of the < tt class = "literal" >< span class = "pre" > reference</ span ></ tt > type is
2004-01-27 17:03:46 +00:00
certainly a defect. Without specification, it is entirely useless in a
generic function. The current practice in the community is generally
2007-06-07 20:53:46 +00:00
to assume there are requirements on the < tt class = "literal" >< span class = "pre" > reference</ span ></ tt > type, such as
2004-01-27 17:03:46 +00:00
those proposed in the new iterator categories.</ p >
< p > There is some danger in < em > adding</ em > requirements to existing concepts.
This will mean that some existing iterator types will no longer meet
the iterator requirements. However, we feel that the impact of this is
small enough to warrant going ahead with this change.</ p >
< p > An alternative solution would be to leave the standard requirements as
2007-06-07 20:53:46 +00:00
is, and to remove the requirements for the < tt class = "literal" >< span class = "pre" > reference</ span ></ tt > type in the
2004-01-27 17:03:46 +00:00
new iterator concepts. We are not in favor of this approach because it
extends what we see as a defect further into the future.</ p >
</ div >
</ div >
2007-06-07 20:53:46 +00:00
< hr class = "footer" />
< div class = "footer" >
< a class = "reference" href = "ref_problem.rst" > View document source</ a > .
Generated by < a class = "reference" href = "http://docutils.sourceforge.net/" > Docutils</ a > from < a class = "reference" href = "http://docutils.sourceforge.net/rst.html" > reStructuredText</ a > source.
</ div >
2004-01-27 17:03:46 +00:00
</ body >
</ html >