I believe that dynamic_cast -does- check that the argument is of the template type, and will return null if the cast fails. I've written some very hairy templated dynamic_cast code that depends on exactly this if / else if / else heirarchical behavior, and it works as expected - the dynamic casting cascades down the conditionals until one of the casts succeeds and returns a non-null result.
Use of dynamic_cast<> does require that you compile with the right flags to turn on run time type identification if your compiler doesn't do it by default.
As for qobject_cast, I have never quite understood why the trolls have felt the need to reinvent wheels that are already working quite well within the Standard C++ Library.




Reply With Quote
Bookmarks