auto + Top-level Const/Immutable
Martin Nowak
dawg at dawgfoto.de
Tue Dec 20 16:02:50 PST 2011
On Tue, 20 Dec 2011 19:16:26 +0100, dsimcha <dsimcha at yahoo.com> 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".
Auto declares a variable initialized with a copy of the rhs expression.
More information about the Digitalmars-d
mailing list