Calculation of a template in dynamic_cast

I have a class that is defined as:

template <class WidgetType>
class CometWidget : public WidgetType;

Inside the function, I do this:

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

and it enables the type CometWidget, matches and runs correctly.
The code is executed inside the CometWidget class. How does this happen?
Why is this so? Should it even compile?

+3
source share
2 answers

If it's inside an ad CometWidget, you don’t need to explicitly specify a template (or any term that you use to say CometWidget<...>).

+2
source

Very interesting. It seems to me that this is an interesting compiler error.

CometWidget < > , . , .

. , "" , .

?

0

Source: https://habr.com/ru/post/1730272/


All Articles