[llvm-commits] Twine/StringRef enhancements & usage

David Blaikie dblaikie at gmail.com
Thu Aug 25 11:20:46 PDT 2011


>
> I think one of the reasons that I've seen SmallVectorImpl instead of
> SmallVector or SmallString for a function parameter is in order to
> avoid having the template parameter that specifies initial size, which
> you would have to do otherwise.


Yes - which is rather strange. Taking something that's not part of the type
& binding it into the type... I don't really see the benefit there. In the
case where you have a SmallString as a member I suppose it would be
moderately inconvenient to override the default size in every ctor you have,
compared to just specifying it as the template parameter, but that seems
marginally beneficial over not having to specify the size whenever you refer
to the type.


> For example, see
> "FindFunctionBackedges" which can be declared in BasicBlockUtils.h and
> defined in BasicBlockUtils.cpp without having template instantiation.
> I don't know if this applies to your situation.


In my particular situation I'm just defining a member
SmallString/Vector/VectorImpl in a trivial type (TwineString, that inherits
from StringRef & has a ctor that takes a Twine & populates the Small<thing>
and itself) so the argument/template disparity between Impl & its
implementations isn't too much of a big deal to me either way. Just quirky.

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110825/0151739d/attachment.html>


More information about the llvm-commits mailing list