
On Feb 27, 2014, at 3:21 PM, Markus Engel wrote:
I think this custom cast is only necessary as long as there are any GLists present. After that we may just use dynamic_cast directly. If the source pointers are correctly typed, the compiler will throw an error on any of the cases the two static_asserts handle. Currently, they are only there to guard against mistakes in the static_cast to ToolBase*. That’s why I directly added it there.
Ideally we can get to the situation where we don't need dynamic_cast<> at all, and code will just work directly with standard C++ inheritance.
In the immediate term, one would like to perhaps just have
PenTool *pc = dynammic_cast<PenTool *>(desktop->event_context); if (pc) { ... } (note that the 'if' and check are dropped, and inspecting the returned pointer for validity then suffices).
Then we should look at cleaning things up so that random down-casting is no longer needed. Much of that is from a C approach to coding, and is not the most efficient for C++.