C++17 cannot beat D surely

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 6 21:12:42 PDT 2017


On 6/6/2017 8:06 PM, Ali Çehreli wrote:
> On 06/06/2017 06:09 PM, Steven Schveighoffer wrote:
> 
>  > But it is pretty well known that enum'ing an array can have it allocate
>  > wherever it is used.
> 
> One of the most effective examples is comparing .ptr with (seemingly) itself:
> 
> void main() {
>      enum e = [ 1 ];
>      static assert(e.ptr != e.ptr);
>      assert(e.ptr != e.ptr);
> }
> 
> Both asserts pass. I'm surprised that e.ptr is usable at compile time. Fine, I 
> guess... :)

One trouble with making them the same is if one of the users of e changes an 
element. Do the rest of the users see the change or the original?


More information about the Digitalmars-d mailing list