Why does sort not work on fixed arrays?

Steven Schveighoffer schveiguy at gmail.com
Tue Sep 17 21:36:50 UTC 2019


On 9/17/19 5:23 PM, Brett wrote:
> T[N] t;
> sort(t); fails
> 
> but
> 
> T[] t;
> sort(t); passes
> 
> 
> but magically
> 
> T[N] t;
> sort(t[0..$]);  passes !!!
> 

std.algorithm.sort accepts a range. A fixed-sized array is not a range, 
since you can't pop the front part off and make it 1 smaller.

You can use sort(t[]) for the same effect.

-Steve


More information about the Digitalmars-d mailing list