문제

I have a class that is defined as the following:

template <class WidgetType>
class CometWidget : public WidgetType;

Inside a function I am doing this:

dynamic_cast<CometWidget *>(iter2->second.second)->changesCommited_();

and it resolves the CometWidget type, complies and run correctly.
The code runs inside the CometWidget class.

How on earth does this happen?
Why is that so? Should it even compile?

도움이 되었습니까?

해결책

뷰 요소에 toolbartemplate="none"을 추가 할 수 있습니다

<View BaseViewID="1" ... ToolbarTemplate="None" ...
.

다른 팁

Very interesting indeed. It seems to me like an interesting compiler bug.

It is possible to deduce the correct argument of the CometWidget<> template - just the same way you can deduce template parameters of a function from argument list. If it would be static cast, it would be less surprising.

With dynamic cast, there's little expected to be in common between the source and the target type. So, such "guessing" might have occurred, but then it's not a rightful one.

What compiler is this?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top