Const initialization issue, looking for solution
deadalnix
deadalnix at gmail.com
Wed May 29 06:19:33 PDT 2013
On Wednesday, 29 May 2013 at 12:43:46 UTC, Jakob Ovrum wrote:
> On Wednesday, 29 May 2013 at 12:40:39 UTC, Dicebot wrote:
>> Why something like this is not usable?
>> -----------------------
>> int tmp;
>> try
>> {
>> tmp = ...;
>> }
>> catch(..)
>> {
>> }
>> const(int) i = tmp;
>> -----------------------
>> Not really pretty but nothing crazy.
>
> const(int) i = tmp; // fails when the type has mutable
> indirection.
I guess the first assignment of a variable should be considered
as a declaration unless it has been read in between. This is the
same problem as immutable constructor, and also relate to extra
copies elimination.
More information about the Digitalmars-d
mailing list