[haiku-development] Re: inline BListView::ScrollTo()
- From: Simon Taylor <simontaylor1@xxxxxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Thu, 28 Feb 2008 08:47:27 +0000
Ingo Weinhold wrote:
On 2008-02-24 at 11:05:34 [+0100], Stephan Assmus <superstippi@xxxxxx> wrote:
there is a BListView::ScrollTo(float x, float y) implemented inline in the
ListView header. BView already has the exact same method. Both call through
to ScrollTo(BPoint) (which is virtual). Can the BListView version be
removed without breaking anything?
C++ has a pretty annoying shadowing behavior in this case. Overriding only
one of several overloaded methods will hide all others. I.e. you won't be
able to invoke ScrollTo(float, float) on a BListView (or derived class)
typed variable anymore. Explicitly invoking BView::ScrollTo(float, float)
would work, but it's probably more convenient to just override this method
as well.
I discussed this in my lab yesterday, and one of the guys went and
looked at the spec - there is a cleaner solution:
class BListView : public BView
{
public:
using BView::ScrollTo(float, float);
...
}
It's like that so that name lookup and overload resolution can happen in
two distinct steps.
Simon
- References:
- [haiku-development] inline BListView::ScrollTo()
- From: Stephan Assmus
- [haiku-development] Re: inline BListView::ScrollTo()
- From: Ingo Weinhold
Other related posts:
- » [haiku-development] inline BListView::ScrollTo()
- » [haiku-development] Re: inline BListView::ScrollTo()
- » [haiku-development] Re: inline BListView::ScrollTo()
On 2008-02-24 at 11:05:34 [+0100], Stephan Assmus <superstippi@xxxxxx> wrote:
there is a BListView::ScrollTo(float x, float y) implemented inline in the ListView header. BView already has the exact same method. Both call through to ScrollTo(BPoint) (which is virtual). Can the BListView version be removed without breaking anything?
C++ has a pretty annoying shadowing behavior in this case. Overriding only one of several overloaded methods will hide all others. I.e. you won't be able to invoke ScrollTo(float, float) on a BListView (or derived class) typed variable anymore. Explicitly invoking BView::ScrollTo(float, float) would work, but it's probably more convenient to just override this method as well.
- [haiku-development] inline BListView::ScrollTo()
- From: Stephan Assmus
- [haiku-development] Re: inline BListView::ScrollTo()
- From: Ingo Weinhold