On 6/18/12, Jonathan M Davis <[email protected]> wrote:
> At that point, you'd need to be converting from string[] to Wrap[],
> which would mean creating a new array
It doesn't have to allocate anything because there's the 'alias this'
and a single data member. All the compiler has to do is cast the array
type to Wrap[]. Casting is safe in this case and should be allowed to
be implicit:
void main()
{
string[] x = ["foo", "bar"];
Wrap[] y = cast(Wrap[])x;
assert(y[0] == "foo"); // safe
}
Of course this only works if there are no other data fields in Wrap
except the string, and that's exactly what I have in this case.