C++17 cannot beat D surely

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 3 16:41:37 PDT 2017


On Saturday, 3 June 2017 at 22:18:06 UTC, Timon Gehr wrote:
>
> There is no mistake. (But 'auto' is redundant.)
>
>> void main() {
>>      import std.algorithm, std.stdio;
>>      enum a = [ 3, 1, 2, 4, 0 ];
>>      enum b = sort(a);// static is not CT !!!!!
>>      static assert(b[0] == 0); // does not pass with static 
>> auto b...
>>      writeln(b);
>> }
>> 
>> 
>
> This is worse. Now there is an allocation at runtime.

So maybe we can do a blog post on when to use static or enum? 
Because smart people don't seem to be agreeing on this...


More information about the Digitalmars-d mailing list