const question/suggestion

Daniel Keep daniel.keep.lists at gmail.com
Mon Jun 18 23:11:39 PDT 2007



James Dennett wrote:
> Walter Bright wrote:
>> Myron Alexander wrote:
>>> const var = new SomeObject ();
>> The above line will fail because const declarations can only be
>> initialized with something that can be evaluated at compile time. The
>> example should be:
>>
>>     const(SomeObject) var = new SomeObject();
> 
> Is there any way to use type deduction to avoid having
> to repeat the SomeObject part of this?
> 
> -- James

auto var = cast(const) new SomeObject();

It's one character shorter :P

	-- Daniel



More information about the Digitalmars-d-announce mailing list