Added copy constructors to "Programming in D"

Walter Bright newshound2 at digitalmars.com
Thu Feb 10 22:40:55 UTC 2022


On 2/10/2022 12:34 PM, Walter Bright wrote:
> On 2/10/2022 12:06 AM, Mathias LANG wrote:
>> I think an *immediate* improvement we could make to ease people's life is to 
>> make `auto` peel the outermost qualifier level inside functions.
>>
>> So that:
>> ```D
>> const int* ptr;
>> auto p2 = ptr;
>> static assert(is(typeof(p2) == const(int)*));
>> ```
>>
>> I really can't think of any downside to it, only upsides:
>> - It is still predictable / consistent;
>> - It *might* reduce the number of template instantiations in some cases;
>> - It just flows more naturally... If you want full constness, there's still 
>> `const`;
> 
> It sounds sensible to me.


By the way, `cast()ptr` will peal off the outermost const/immutable/etc from the 
type.


More information about the Digitalmars-d-announce mailing list