Why does sort not work on fixed arrays?

Jonathan Marler johnnymarler at gmail.com
Tue Sep 17 21:33:52 UTC 2019


On Tuesday, 17 September 2019 at 21:23:53 UTC, Brett wrote:
> T[N] t;
> sort(t); fails
>
> but
>
> T[] t;
> sort(t); passes
>
>
> but magically
>
> T[N] t;
> sort(t[0..$]);  passes !!!

I believe T[N] t; sort(t); would pass t by value, so the sort 
function would actually do nothing to t, it would only operate on 
a copy of t that was passed on the stack.



More information about the Digitalmars-d mailing list