Auto keyword with const variable

dennis luehring dl.soluz at gmx.net
Wed Jul 24 02:46:48 PDT 2013


Am 24.07.2013 11:39, schrieb bearophile:
> Alex H:
>
>> void test(const int n)
>> {
>> 	auto j = n;
>> 	j++;
>> }
>>
>> Gives this error:
>> cannot modify const expression j
>>
>>
>> Is this considered a feature or a bug? I would assume most
>> people wouldn't want new variables inheriting const.
>
> It's a bit annoying. I don't remember people discussing this
> small problem. I don't know if it's easy to "fix" it and what
> side effects such change could cause.

should that be fixed - i don't think that any auto removal of
const, immutable, shared or anything else should just happen silently

and how would it look to preserve the const if auto would auto-rip it of?





More information about the Digitalmars-d-learn mailing list