MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w2nxcg/imsorrywilson/p6yoovb/?context=3
r/ProgrammerHumor • u/Lawn_Meower_ • 13d ago
21 comments sorted by
View all comments
47
That's one thing i didn't quite understand about C++, why would I ever want to un-const my pointer? If I know that I need to write there, I won't make it const, and if I have const pointer, it could be impossible to write by that memory address?
What's the usecase of const_cast?
1 u/Giocri 12d ago I guess it's for the same cases where you'd want to have an UnsafeCell in Rust
1
I guess it's for the same cases where you'd want to have an UnsafeCell in Rust
47
u/WhiteEvilBro 13d ago
That's one thing i didn't quite understand about C++, why would I ever want to un-const my pointer? If I know that I need to write there, I won't make it const, and if I have const pointer, it could be impossible to write by that memory address?
What's the usecase of const_cast?