| 1 | <?xml version="1.0" encoding="utf-8" ?> | 
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 
|---|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | 
|---|
| 4 | <head> | 
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 
|---|
| 6 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> | 
|---|
| 7 | <title>Problem with reference and old/new iterator category correspondance</title> | 
|---|
| 8 | <link rel="stylesheet" href="default.css" type="text/css" /> | 
|---|
| 9 | </head> | 
|---|
| 10 | <body> | 
|---|
| 11 | <h1 class="title">Problem with <tt class="literal"><span class="pre">reference</span></tt> and old/new iterator category correspondance</h1> | 
|---|
| 12 | <div class="document" id="problem-with-reference-and-old-new-iterator-category-correspondance"> | 
|---|
| 13 | <table class="field-list" frame="void" rules="none"> | 
|---|
| 14 | <col class="field-name" /> | 
|---|
| 15 | <col class="field-body" /> | 
|---|
| 16 | <tbody valign="top"> | 
|---|
| 17 | <tr class="field"><th class="field-name">Author:</th><td class="field-body">David Abrahams and Jeremy Siek</td> | 
|---|
| 18 | </tr> | 
|---|
| 19 | <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> | 
|---|
| 20 | </tr> | 
|---|
| 21 | <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> | 
|---|
| 22 | </tr> | 
|---|
| 23 | <tr class="field"><th class="field-name">date:</th><td class="field-body">$Date: 2004/11/02 14:31:13 $</td> | 
|---|
| 24 | </tr> | 
|---|
| 25 | <tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Copyright David Abrahams, Jeremy Siek 2003. Use, modification and | 
|---|
| 26 | distribution is subject to the Boost Software License, | 
|---|
| 27 | Version 1.0. (See accompanying file LICENSE_1_0.txt or copy | 
|---|
| 28 | at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</td> | 
|---|
| 29 | </tr> | 
|---|
| 30 | </tbody> | 
|---|
| 31 | </table> | 
|---|
| 32 | <div class="section" id="introduction"> | 
|---|
| 33 | <h1><a name="introduction">Introduction</a></h1> | 
|---|
| 34 | <p>The new iterator categories are intended to correspond to the old | 
|---|
| 35 | iterator categories, as specified in a diagram in <a class="reference" href="http://www.boost-consulting.com/writing/n1550.html">N1550</a>. For example, | 
|---|
| 36 | an iterator categorized as a mutable Forward Iterator under the old | 
|---|
| 37 | scheme is now a Writable, Lvalue, and Foward Traversal iterator. | 
|---|
| 38 | However, there is a problem with this correspondance, the new iterator | 
|---|
| 39 | categories place requirements on the <tt class="literal"><span class="pre">iterator_traits<X>::reference</span></tt> | 
|---|
| 40 | type whereas the standard iterator requirements say nothing about the | 
|---|
| 41 | <tt class="literal"><span class="pre">reference</span></tt> type . In particular, the new Readable Iterator | 
|---|
| 42 | requirements say that the return type of <tt class="literal"><span class="pre">*a</span></tt> must be | 
|---|
| 43 | <tt class="literal"><span class="pre">iterator_traits<X>::reference</span></tt> and the Lvalue Iterator requirements | 
|---|
| 44 | 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> | 
|---|
| 45 | <span class="pre">T&</span></tt>.</p> | 
|---|
| 46 | </div> | 
|---|
| 47 | <div class="section" id="proposed-resolution"> | 
|---|
| 48 | <h1><a name="proposed-resolution">Proposed Resolution</a></h1> | 
|---|
| 49 | <p>Change the standard requirements to match the requirements of the new | 
|---|
| 50 | iterators. (more details to come)</p> | 
|---|
| 51 | </div> | 
|---|
| 52 | <div class="section" id="rationale"> | 
|---|
| 53 | <h1><a name="rationale">Rationale</a></h1> | 
|---|
| 54 | <p>The lack of specification in the standard of the <tt class="literal"><span class="pre">reference</span></tt> type is | 
|---|
| 55 | certainly a defect. Without specification, it is entirely useless in a | 
|---|
| 56 | generic function. The current practice in the community is generally | 
|---|
| 57 | to assume there are requirements on the <tt class="literal"><span class="pre">reference</span></tt> type, such as | 
|---|
| 58 | those proposed in the new iterator categories.</p> | 
|---|
| 59 | <p>There is some danger in <em>adding</em> requirements to existing concepts. | 
|---|
| 60 | This will mean that some existing iterator types will no longer meet | 
|---|
| 61 | the iterator requirements. However, we feel that the impact of this is | 
|---|
| 62 | small enough to warrant going ahead with this change.</p> | 
|---|
| 63 | <p>An alternative solution would be to leave the standard requirements as | 
|---|
| 64 | is, and to remove the requirements for the <tt class="literal"><span class="pre">reference</span></tt> type in the | 
|---|
| 65 | new iterator concepts. We are not in favor of this approach because it | 
|---|
| 66 | extends what we see as a defect further into the future.</p> | 
|---|
| 67 | </div> | 
|---|
| 68 | </div> | 
|---|
| 69 | <hr class="footer" /> | 
|---|
| 70 | <div class="footer"> | 
|---|
| 71 | <a class="reference" href="ref_problem.rst">View document source</a>. | 
|---|
| 72 | 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. | 
|---|
| 73 | </div> | 
|---|
| 74 | </body> | 
|---|
| 75 | </html> | 
|---|