<h1class="title">Problem with <ttclass="literal"><spanclass="pre">is_writable</span></tt> and <ttclass="literal"><spanclass="pre">is_swappable</span></tt> in <aclass="reference"href="http://www.boost-consulting.com/writing/n1550.html">N1550</a></h1>
<trclass="field"><thclass="field-name">Organization:</th><tdclass="field-body"><aclass="reference"href="http://www.boost-consulting.com">Boost Consulting</a>, Indiana University Bloomington</td>
<p>The <ttclass="literal"><spanclass="pre">is_writable</span></tt> and <ttclass="literal"><spanclass="pre">is_swappable</span></tt> traits classes in <aclass="reference"href="http://www.boost-consulting.com/writing/n1550.html">N1550</a>
provide a mechanism for determining at compile time if an iterator
type is a model of the new Writable Iterator and Swappable Iterator
concepts, analogous to <ttclass="literal"><spanclass="pre">iterator_traits<X>::iterator_category</span></tt>
for the old iterator concepts. For backward compatibility,
<ttclass="literal"><spanclass="pre">is_writable</span></tt> and <ttclass="literal"><spanclass="pre">is_swappable</span></tt> not only work with new
iterators, but they also are intended to work for old
iterators (iterators that meet the requirements for one of the
iterator concepts in the current standard). In the case of old
iterators, the writability and swapability is deduced based on the
<ttclass="literal"><spanclass="pre">iterator_category</span></tt> and also the <ttclass="literal"><spanclass="pre">reference</span></tt> type. The
specification for this deduction gives false positives for forward
iterators that have non-assignable value types.</p>
<p>To review, the part of the <ttclass="literal"><spanclass="pre">is_writable</span></tt> trait definition which
<p>Suppose the <ttclass="literal"><spanclass="pre">value_type</span></tt> of the iterator <ttclass="literal"><spanclass="pre">It</span></tt> has a private
<p>and suppose the <ttclass="literal"><spanclass="pre">reference</span></tt> type of the iterator is <ttclass="literal"><spanclass="pre">B&</span></tt>. In
that case, <ttclass="literal"><spanclass="pre">is_writable<It>::value</span></tt> will be true when in fact
attempting to write into <ttclass="literal"><spanclass="pre">B</span></tt> will cause an error.</p>
<p>The same problem applies to <ttclass="literal"><spanclass="pre">is_swappable</span></tt>.</p>
<li><pclass="first">Remove the <ttclass="literal"><spanclass="pre">is_writable</span></tt> and <ttclass="literal"><spanclass="pre">is_swappable</span></tt> traits, and remove the
requirements in the Writable Iterator and Swappable Iterator concepts
that require their models to support these traits.</p>
</li>
<li><pclass="first">Change the <ttclass="literal"><spanclass="pre">is_readable</span></tt> specification to be:
<ttclass="literal"><spanclass="pre">is_readable<X>::type</span></tt> is <ttclass="literal"><spanclass="pre">true_type</span></tt> if the
result type of <ttclass="literal"><spanclass="pre">X::operator*</span></tt> is convertible to
<ttclass="literal"><spanclass="pre">iterator_traits<X>::value_type</span></tt> and is <ttclass="literal"><spanclass="pre">false_type</span></tt>