<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - ostream_iterator::operator* is not constant"
   href="http://llvm.org/bugs/show_bug.cgi?id=19425">19425</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ostream_iterator::operator* is not constant
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>root@zta.lk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>There is a trick used in ostream_iterator, that doesn't quite conform to
standard.

ostream_iterator<T>::operator* returns itself instead of something with
operator=(const T &);

It's almost never an issue since the all the stl algorithms do * and ++ at the
same time. But if we separate * and ++ the way that is shown below, the program
won't compile.

---------
#include <iostream>
#include <iterator>

using namespace std;

void write_5(const ostream_iterator<int> &i)
{
    *i = 5;
}

int main()
{
    ostream_iterator<int> i(cout);
    write_5(i);
    ++i;
}
---------

I believe ostream_iterato<T>::operator* must be defined as const and return a
temporary object, that holds the reference to the stream and have operator=
that do the job. In any case, the code above conforms to standard and doesn't
compile.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>