21.2. const_cast Operator
C++ provides the const_cast operator for casting away
volatile qualification. You declare a variable with the volatile qualifier when you expect the variable to be modified by hardware or other programs not known to the compiler. Declaring a variable
volatile indicates that the compiler should not optimize the use of that variable because doing so could affect the ability of those other programs to access and modify the
In general, it’s dangerous to use the
const_cast operator, because it allows a program to modify a variable that was declared
const. There are cases in which it’s desirable, or even necessary, to cast away
const-ness. For example, older C and C++ libraries might provide functions ...