I know that dynamic_cast have runtime check and therefor consider safer (can return null pointer on failure) but slower then static_cast. but how bad is the overhead between the two?
should I realy consider use static_cast in loops for performance issues in regular large projects? or the difference is minor and only relevant for special real-time programs.
Did you profile it?
The rule is:
static_castwhen you know that the target type is valid.dynamic_castwhen you’re not sure, and you need the program to look up the object’s runtime type for you.It’s as simple as that. All other considerations are secondary.