the const correctness of the this pointer

Jason House jason.james.house at gmail.com
Sun Dec 27 16:14:09 PST 2009


TM Wrote:

> Hello, 
> I was dealing with delegates when I found that the const correctness of the this pointer was 'lost' when accessing a member function of a class through a temporary delegate. 
> 
> Here is an example:
> 
> class A{
>     void f () {}
> }
> 
> const A a = new A;
> a.f() //error, this is normal.
> auto g = &a.f;
> g(); //no error. Is this normal ?
> 
> I may be wrong, but it seems to me that as the const property of the this pointer is linked to the instance of the class (here 'a'), the delegate 'g' should contain a const pointer to A (because 'a' is const).


Looks like something that should be entered into bugzilla





More information about the Digitalmars-d mailing list