Stripping away const/invariant in D 2.0

Christian Kamm kamm.incasoftware at shift-at-left-and-remove-this.de
Tue Aug 28 23:16:00 PDT 2007


Bruno Medeiros wrote:
>>> Use "typeof(T)". For example if T is invariant char , then typeof(T) ==
>>> char. typeof() kinda works like a declaration, so it removes the top
>>> level const/invariant.
>>> 
Christian Kamm wrote:
>> This works for plan data like char (since const(char) really is the same
>> type as char, if I understand it right - there's no 'tail' that could be
>> const), but not for reference types:
>>
Bruno Medeiros wrote:
> I know that, that's what I meant when I said it removes "the top level"
> const/invariant. Maybe not the best of terminology, it was just
> something that I had used before. And I haven't read about this new
> head/tail stuff yet.

Ah, I misunderstood then. Also, I didn't know that stripping of the 'top
level' const would only happen in declarations, so Stewart Gordon's
solution baffled me at first.

Christian



More information about the Digitalmars-d mailing list