3 ms·
The point is that one shouldn't do it accidentally. When you're explicitly using const_cast, it is fine.
by zura 13y ago
The point is that one shouldn't do it accidentally. When you're explicitly using const_cast, it is fine.
- zura 13y agoI should clarify that it is fine in a local context, when you know that originally it is a non-const variable. Otherwise, the result is undefined. But what I meant in the above comment is that you can't accidentally type "const_cast". So when you type it, you're on your own. And there is nothing wrong with it in C++ world - if you explicitly state that you want to shoot yourself in the foot, the compiler will just listen to your orders (maybe with some warnings).