If you've decided to group together all the drawable objects, then presumably that's for the purpose of drawing them. So you don't need to have any dynamic casts.
You have a container of
sf::Drawable*
, in which the "draw_yourself" function is virtual, and you simply call "draw_yourself" on every object pointed to in the container. No dynamic-casting in sight.
Because they're pointers, if you then need a container of things that can have text set on them, you could have a container of
sf::thingsToSetTextOn*
which point to the exact same objects as the other container does. That said, I think this design needs revisiting.
And I could name my objects. |
That's nice. Do you particularly like naming things? What's the need for it? Don't solve problems you don't have.
Plus wouldn't unordered_map be faster? |
For iterating through, I wouldn't have thought so. However, the odds of it mattering for your purposes are extraordinarily low. Spend your time fixing real problems, not imagined performance issues.
If your design requires you to have some extra way of keeping track of what kind of object things are, external to the objects, step back and redesign it.