Wednesday, September 8, 2010

const_cast<>() and the volatile type qualifier

You can use const_cast<>() to remove the volatile qualifier.

Reference: The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 20.

I tried this on a couple of compilers.

It worked on the IBM AIX compiler, but it did not work on the Sun compiler.

It only worked for references, pointers and pointers to data members.

See also: volatile - Multithreaded Programmer's Best Friend by Andrei Alexandrescu.

No comments:

Post a Comment