Bizarre way to 'new' arrays

Tom S h3r3tic at remove.mat.uni.torun.pl
Fri Jun 16 01:03:31 PDT 2006


Sean Kelly wrote:
> Sadly, this isn't legal:
> 
>     int* i = new int(5);
> 
> To allocate and initialize an integer.  AFAIK there's no way around 
> having the assignment as a separate statement following the allocation.

int* i = (new int)[0..1] = 5;


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d mailing list