Relaxing the definition of isSomeString and isNarrowString

Peter Alexander via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 24 10:50:17 PDT 2014


On Sunday, 24 August 2014 at 01:06:31 UTC, Andrei Alexandrescu 
wrote:
> I'm thinking of relaxing the definitions to all types that 
> fulfill the following requirements:
>
> * are random access ranges
> * element type is some character
> * offer .ptr as a @system property that offers a pointer to the 
> first character

Hmm, you also need .length, but it needs to return the length of 
the encoding, not the string. There might be custom string types 
where .length returns the number of code points, but where .ptr 
points to code units.

Narrow string optimized functions will also be looking for an 
opSlice that is indexed by code units.



More information about the Digitalmars-d mailing list