3 ms·
Normally (when containers are not involved) this is exactly the point of a const cast.
by morelisp 4y ago
Normally (when containers are not involved) this is exactly the point of a const cast.
- account42 4y agoNo, the primary point of a const cast is "I need to pass this to an API that expects a non-const pointer even though it won't mutate it". Casting const away and then mutating is a footgun as you are in undefined behavior territory as soon as your pointer/reference is not just const itself but points to a const variable.