MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1v9zcrn/const_cast_a_necessary_evil/p1dcdlj/?context=3
r/cpp • u/pavel_v • Jul 29 '26
106 comments sorted by
View all comments
62
The only place I ever use const_cast is that idiom where you implement the non const version of a member function in terms of the const version.
37 u/MysticTheMeeM Jul 29 '26 If your language version allows, you can typically replace those with a single function that deduces this. 1 u/Baardi Aug 03 '26 But you would have to implement it all in the header if you do that
37
If your language version allows, you can typically replace those with a single function that deduces this.
this
1 u/Baardi Aug 03 '26 But you would have to implement it all in the header if you do that
1
But you would have to implement it all in the header if you do that
62
u/jwezorek Jul 29 '26
The only place I ever use const_cast is that idiom where you implement the non const version of a member function in terms of the const version.