std.string.join & co. do a character-by-character copy because hasLength!string is false

KennyTM~ kennytm at gmail.com
Fri May 27 11:29:10 PDT 2011


On May 28, 11 02:05, Vladimir Panteleev wrote:
> Why hasLength!string is false:
> https://github.com/D-Programming-Language/phobos/blob/96941d5384a5fee302df/std/range.d#L767
>
>
> Would it make sense to introduce a hasOpaqueLength oslt. to fix this?
>

You mean std.array.join? The 2-argument overload has specialization for 
strings 
(https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L966).

     static if (isForwardRange!RoR && hasLength!RoR
             && (hasLength!(ElementType!RoR) || 
isSomeString!(ElementType!RoR))
// 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             && hasLength!R)

It doesn't exist for the 1-argument overload though.


More information about the Digitalmars-d mailing list