3 ms·
const_cast<> isn't the root of the problem. If someone passes you a pointer to a const pointer to a non-const thing, they can still just mutate the non-const th
by plorkyeran 11y ago
const_cast<> isn't the root of the problem. If someone passes you a pointer to a const pointer to a non-const thing, they can still just mutate the non-const thing without any casts. You'd have to forbid non-const to const pointer conversions entirely (which would imply removing const_cast<>, as there would no longer be any situations in which it was legal to use).
- jjuhl 11y agoRight. There are lots of corner cases that would need to be identified and considered in the case of a "strong const" C++ variant (like what you point out) - I still think it could be an interresting experiment.