const again

Christopher Wright dhasenan at gmail.com
Thu Dec 6 16:27:58 PST 2007


Walter Bright wrote:
> Christopher Wright wrote:
>>> I've given up on tail const in any of its forms. The new regime has 
>>> no tail const, no head const, it's just const, and fully transitive 
>>> const at that.
>>
>> So if I have:
>> const(Foo)* t;
>> the pointer is const and points to a const Foo?
> 
> No, it is a mutable pointer to a const Foo. A const pointer to a const 
> Foo would be:
>     const(Foo*) t;
> 
>> Will that fail?
> 
> Yes, because T[] will be the same thing as const(Foo)[]. Hiding it 
> behind an alias and a template won't change that <g>.

So why do arrays take their const status from their elements when 
pointers don't?



More information about the Digitalmars-d mailing list