I would like to compare a list of component and sort them according to their class type. Is there a method to retrieve the class name from a component? For example Slider or ToggleButton. None of the components have names when I do this sorting so I can’t check them. I’m sure I saw a way to do this some time ago but I couldn’t find anything in the “Component” entry to the manual. Perhaps I missed it.
void print (Component* component)
std::cout << typeid (*component).name() << std::endl;
Note that this is really slow to execute so it should stay in debug code or just for testing purpose.
If you use that typeid in production code instead of a Visitor pattern or something like that, then you’d better pray for your soul every day at the C++ reformed church