Your problem generalises to anything "streamy"<br><br>Going way back to the old C way of doing things<br> FILE * f;<br> fprintf(f, fmt, stuff);<br><br>You'd expect that to work, even if you copied from from inside a const struct, right? But then the type of f would have to change to
<br><br> const FILE * f; <br><br>which is C-speak for "f is a const pointer to mutable FILE". Now throwing in transitivity would stop it all working.<br><br>Moving forward in time to the modern era of objects, in general, you would want:
<br><br> stream.write(x);<br><br>to work even if the variable "stream" was const. (That is, if the /reference/ was const, not the data which is pointed to by the reference). The stack variable can be const, but the heap data needs to be mutable.
<br><br>I don't have a solution, except to agree that "head const" does seem to be required after all.<br>