The Status of Const
Graham St Jack
Graham.StJack at internode.on.net
Thu Aug 12 18:16:01 PDT 2010
On 13/08/10 10:18, Jonathan M Davis wrote:
> On Thursday, August 12, 2010 17:38:28 Graham St Jack wrote:
>
>> For me, the key problem is that a class object reference has the same
>> const/immutable/shared attribute as the object on the heap that it
>> refers to. This is sometimes what you need, but more often you want a
>> non-shared, mutable reference to a const/immutable/shared object.
>>
>> You can achieve this with pointers for arrays, structs and primitive
>> types, but not with classes because a class pointer is just a pointer to
>> a reference.
>>
> Hence the hack that is Rebindable!().
>
> Oh, and you _can_ achieve pointers to classes, but what you normally use are
> references, which do have the problem of not being able to be split between the
> reference and referent types.
>
> - Jonathan M Davis
>
So how do you get a pointer to an object? Taking the address of an
object reference gives you a pointer to the reference, not the object,
which is fair enough. As far as I know there isn't a way to get a
pointer to the object itself, and even if you could, how do you use such
a thing?
--
Graham St Jack
More information about the Digitalmars-d
mailing list