What inherent advantages do boost::any and boost::any_cast offer over using void* and dynamic_cast?
What inherent advantages do boost::any and boost::any_cast offer over using void* and dynamic_cast ?
Share
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.
The advantage is that
boost::anyis way more type-safe thanvoid*.E.g.
As to your comment, you cannot
dynamic_castfrom avoid*. You candynamic_castonly from pointers and references to class types which have at least one virtual function (aka polymorphic types)