<div dir="rtl"><div dir="ltr">SmallString has implicit conversion to StringRef: </div><div dir="ltr"><br></div><div dir="ltr"> operator StringRef() const { return str(); }</div><div dir="ltr"><br></div><div dir="ltr">Explicit .str() helps when you want to use one of the StringRef useful member functions without using an explicit StringRef temporary, such as:</div><div dir="ltr"><br></div><div dir="ltr">  SmallString<128> Name;</div><div dir="ltr">  if (Name.str().startswith("blah"))</div><div><br></div><div dir="ltr">StringRef does not have a constructor from SmallString probably to avoid circular dependency.</div><div dir="ltr"><br></div><div dir="ltr">BTW, .str() is already inconsistent since SmallString.str() is StringRef but StringRef.str() is std::string.</div><div dir="ltr"><br></div><div dir="ltr">As for name, would SmallString.to_string() be better?<br></div><div dir="ltr"><br></div></div><div class="gmail_extra"><div dir="ltr"><br><div class="gmail_quote">2014-10-15 18:12 GMT+03:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">using the same identifier as a standard type like 'string' is probably a bit sketchy... though I'm not sure what other names might suit<br><br>Why does SmallString need an explicit StringRef-izing function anyway (thus freeing up the name 'str')? That seems like a reasonable implicit conversion that'd rarely be needed to be explicit... but perhaps I'm wrong.</blockquote></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Oct 15, 2014 at 2:53 AM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="rtl"><div dir="ltr">SmallString conversion to std::string is currently done by going through a StringRef, S.str().str(). This patch provides a direct conversion function, S.string().</div><span><font color="#888888"><div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></font></span></div>
<br></span>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div></div>