3 ms·
const_cast is undefined behavior if the actual object is const. If it's a mutable object that just happened to be passed as a reference you can const_cast it. O
by aristidb 13y ago
const_cast is undefined behavior if the actual object is const. If it's a mutable object that just happened to be passed as a reference you can const_cast it. Or that's how I understand it.
- ajuc 13y agoThe funny thing is - it doesn't even show a warning compiled with -Wall.
- alexchamberlain 13y agoWell, the `const_cast` usage is fine, but calling that function on an actual `const` object is not; it's a lot to ask a compiler to warn on that.