const again

Christopher Wright dhasenan at gmail.com
Fri Dec 7 05:49:09 PST 2007


Walter Bright wrote:
> Christopher Wright wrote:
>> 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?
> 
> ??? I think there's a misunderstanding here on what arrays are. Arrays 
> consist of a pointer/length pair. As far as const goes, they are just 
> like pointers.

But I can reassign a const Foo, right?



More information about the Digitalmars-d mailing list