[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: [PATCH] Optimize pointers to member function
From:       John McCall <rjmccall () apple ! com>
Date:       2013-02-14 22:25:57
Message-ID: 8D371FAC-3AAF-4994-BBA4-52458E3A2552 () apple ! com
[Download RAW message or body]

On Feb 14, 2013, at 2:15 PM, Olivier Goffart <ogoffart@kde.org> wrote:
> On Thursday 14 February 2013 13:49:23 John McCall wrote:
>> On Feb 14, 2013, at 1:42 PM, Olivier Goffart <ogoffart@kde.org> wrote:
> 
>>> There I read:
>>>  [...] If class B contains the original member, or is a base or derived
>>>  class of the class containing the original member, the resulting pointer
>>>  to  member points to the original member. Otherwise, the result of the
>>>  cast is undefined.
>>> 
>>>> int main() { void (A::*t)() = (void(A::*)())&B::n; }
>>> 
>>> So that cast is undefined.
>> 
>> The original member is B::n, and A is a base class of the class containing
>> the original member.
> 
> Ah right.
> Turns out I was wrong :-)
> Sorry for the noise.

Well, we could still pursue optimizations like this in the presence of final
classes.  Most people don't aggressively make their classes final, but if
you tell them that there's an optimization if they do...  Of course, it's up to
you whether you still care enough to pursue this in that case.

In fact, if the class of the base expression is final, we can skip not just
the this-adjustment, but also potentially the entire virtual or non-virtual case
depending on the type of the member we're calling.

John.
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic