How to cast away the volatile-ness? Which c++ style cast should I use?
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.
Use
const_cast.For example,
That is,
const_castis used to cast away both const-ness as well as volatile-ness. Unfortunately, its name doesn’t contain the term “volatile”. Maybe, that is because the keywordconstis more common in use than the keywordvolatile. As one of the comment says,cv_castwould have been more appropriate name!