Implicit conversion to mutable if no indirections?

Meta jared771 at gmail.com
Sun Sep 4 14:45:15 UTC 2022


On Sunday, 4 September 2022 at 12:33:37 UTC, Mathias LANG wrote:
> On Sunday, 4 September 2022 at 11:03:53 UTC, Nick Treleaven 
> wrote:
>> On Friday, 2 September 2022 at 18:58:43 UTC, Ali Çehreli wrote:
>>> But I am aware that we can't deduce T to be 'int' because we 
>>> would be losing that qualifier and further template 
>>> deductions would be wrong. :/
>>
>> Another feature that would be interesting is if an `auto` 
>> declaration stripped const/immutable where possible. After 
>> all, if the user didn't want that they could've used `const` 
>> or `immutable`.
>>
>> ```d
>> const i = 4; // const int
>> auto v = i;  // int
>> const a = [0]; // const(int[])
>> auto s = a;    // const(int)[]
>> ```
>
> This has been discussed in another thread and Walter approved 
> it. Just need to implement it.

He did? This is straight out of Scott Myers' "The Last Thing D 
Needs" talk. He uses almost the same code as an example too.


More information about the Digitalmars-d mailing list