r/cpp • • Jul 29 '26

const_cast: A Necessary Evil

https://www.elbeno.com/blog/?p=1858
70 Upvotes

106 comments sorted by

View all comments

Show parent comment

14

u/No-Dentist-1645 Jul 29 '26

unless you’re talking about bad C libraries, in which case why are you using them?

This happens way more often than you think, especially in "legacy" projects. You often don't have the time nor resources needed to rewrite an entire library your company has used for over 10 years that "just works", but isn't const-correct for some functions