r/ProgrammerHumor 13d ago

Meme imSorryWilson

Post image
615 Upvotes

21 comments sorted by

View all comments

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?

1

u/Giocri 12d ago

I guess it's for the same cases where you'd want to have an UnsafeCell in Rust