[PATCH] Change StringRef size_t instances to size_type

Chris Lattner clattner at apple.com
Thu May 2 13:16:06 PDT 2013


On May 2, 2013, at 9:22 AM, Aaron Ballman <aaron at aaronballman.com> wrote:

> 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.

LGTM!

-Chris

> 
> ~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
>> 
> <StringRef.h.patch>




More information about the llvm-commits mailing list