[phobos] array() function
David Simcha
dsimcha at gmail.com
Thu Jan 20 20:17:34 PST 2011
I wrote this when I was cleaning up array(). The use case for it is
that, in generic code, you generally assume that calling array() on a
range will result in you receiving a random access range. This makes
that assumption valid even for narrow strings. In other words, it
eliminates an ugly special case.
On 1/20/2011 10:59 PM, Andrei Alexandrescu wrote:
> I'm seeing a recently-added overload of array() that spells:
>
> ==========
> ElementType!(String)[] array(String)(String str);
>
> Convert a narrow string to an array type that fully supports
> random access. This is handled as a special case and always returns a
> dchar[], const(dchar)[], or immutable(dchar)[] depending on the
> constness of the input.
> ==========
>
> What are some good use cases for it?
>
>
> Andrei
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
More information about the phobos
mailing list