[PATCH] Change StringRef size_t instances to size_type

Aaron Ballman aaron at aaronballman.com
Thu May 2 09:22:15 PDT 2013


Thank you for the explanation!  I was thinking we were attempting to
model StringRef after std::string, which uses size_type everywhere,
hence the confusion.  I've attached a patch that goes the other
direction and standardizes on size_t instead of size_type.

~Aaron

On Thu, May 2, 2013 at 1:56 AM, Chris Lattner <clattner at apple.com> wrote:
>
> On May 1, 2013, at 5:06 PM, Chandler Carruth <chandlerc at google.com> wrote:
>
> On Thu, May 2, 2013 at 1:02 AM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
>>
>> Then wouldn't it make sense for our APIs (at least the ones STL-ish)
>> to use size_type in case someone wants to vary it?
>
>
> It makes sense for an *algorithm* to use size_type of a data structure it
> operates on in the event the data structure overrides it.
>
> It makes sense for a data structure to use 'size_t' because its simpler.
>
> It makes sense for a data structure to typedef 'size_t' to 'size_type' to
> tell algorithms that it has elected to use that definition.
>
>
>
> Yep, what Chandler said.  There is no reasonable way to vary it in
> StringRef, so the abstraction would just obfuscate the code.
>
> -Chris
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: StringRef.h.patch
Type: application/octet-stream
Size: 2352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130502/ea637d8a/attachment.obj>


More information about the llvm-commits mailing list