<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 12, 2014 at 5:25 AM, Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":5ch" class="a3s" style="overflow:hidden">Replaces the pattern:<br>
<br>
std::string buf;<br>
raw_string_ostream os(buf);<br>
...<br>
os.flush();<br>
use(buf);<br></div></blockquote><div><br></div><div>So this pattern should be:</div><div><br></div><div> std::string buf;</div><div> raw_string_ostream os(buf);</div><div> ...</div><div> use(os.str());</div><div> <br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":5ch" class="a3s" style="overflow:hidden">with:<br>
StringBuilder os;<br>
...<br>
use (os.str());<br></div></blockquote><div><br></div><div>Which is now almost identical to this. What's the advantage?</div><div><br></div><div>The reason I like the current form is that it makes it obvious and easy to re-use storage where that is reasonable, and it makes variations with SmallString more obviously the same pattern with a different storage.</div>
<div><br></div><div>We could even add a 'make_raw_ostream' or some such so that the pattern can become:</div><div><br></div><div> Foo storage;</div><div> auto os(make_raw_ostream(storage));</div><div> ...</div>
<div> use(os.str());</div><div><br></div><div>Thoughts?</div></div></div></div>