Introduce StringBuilder utility around raw_string_ostream
Chandler Carruth
chandlerc at google.com
Thu Jun 12 04:33:12 PDT 2014
On Thu, Jun 12, 2014 at 5:25 AM, Alp Toker <alp at nuanti.com> wrote:
> Replaces the pattern:
>
> std::string buf;
> raw_string_ostream os(buf);
> ...
> os.flush();
> use(buf);
>
So this pattern should be:
std::string buf;
raw_string_ostream os(buf);
...
use(os.str());
> with:
> StringBuilder os;
> ...
> use (os.str());
>
Which is now almost identical to this. What's the advantage?
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.
We could even add a 'make_raw_ostream' or some such so that the pattern can
become:
Foo storage;
auto os(make_raw_ostream(storage));
...
use(os.str());
Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140612/7da76264/attachment.html>
More information about the llvm-commits
mailing list