auto + Top-level Const/Immutable
Timon Gehr
timon.gehr at gmx.ch
Tue Dec 20 10:39:02 PST 2011
On 12/20/2011 07:16 PM, dsimcha wrote:
> On Tuesday, 20 December 2011 at 17:46:40 UTC, Jonathan M Davis wrote:
>> Assuming that the assignment can still take place, then making auto
>> infer non-
>> const and non-immutable would be an improvement IMHO. However, there
>> _are_ cases where you'd have to retain const - a prime example being
>> classes. But value types could have const/immutable stripped from
>> them, as could arrays using their tail-constness.
>>
>> - Jonathan M Davis
>
> Right. The objects would only be head de-constified if Michael Fortin's
> patch to allow such things got in. A simple way of explaining this would
> be "auto removes top level const from the type T if T implicitly
> converts to the type that would result".
Yes, having to use
auto x = cast()y;
is quite annoying, I'd like this change to happen.
BTW: What will happen with cast()classRef once we have head-mutable
class references?
More information about the Digitalmars-d
mailing list