Quick int pointer allocation question

monarch_dodra monarchdodra at gmail.com
Fri Sep 14 08:11:31 PDT 2012


On Friday, 14 September 2012 at 14:33:51 UTC, Steven 
Schveighoffer wrote:
> On Fri, 14 Sep 2012 05:20:16 -0400, monarch_dodra 
> <monarchdodra at gmail.com> wrote:
>
>> This is going to be quick: Is it possible to allocate and 
>> initialize an int in the same line?
>>
>> int* p = new int(5);
>>
>> I haven't found a way to 1 liner it. Is it possible?
>> Do I have to two liner it?
>>
>> int* p = new int();
>> *p = 5;
>
> int *p = [5].ptr;
>
> -Steve

Fancy!

Thankyou.


More information about the Digitalmars-d-learn mailing list