Const initialization issue, looking for solution

Steven Schveighoffer schveiguy at yahoo.com
Wed May 29 14:45:17 PDT 2013


On Wed, 29 May 2013 08:43:44 -0400, Jakob Ovrum <jakobovrum at gmail.com>  
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.

Everything mutable and immutable (and const, or inout) is implicitly  
convertible to const.  The above should work for any type of tmp.

Can you cite specific code that is failing?

-Steve


More information about the Digitalmars-d mailing list