It seems everywhere I read that either a library boasts if not needing RTTI or an article advises against its use. What is so bad about it and why is it such a good thing not to need it?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because using it usually means you are subverting polymorphism (
if (type is foo) { do this; } else if (type is bar) { do that; } else ...), which usually means you have engineered yourself into a corner and need to rethink your design.Because authors of C++ compilers put a lot of effort into optimising polymorphic behaviour, but less so into optimising use of RTTI.