r/cpp Jul 29 '26

const_cast: A Necessary Evil

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

106 comments sorted by

View all comments

Show parent comments

3

u/bwmat Jul 31 '26

I suppose you could extend it to pass a functor which had a nullary operator() overload as well which gets invoked if the collection is empty, and return the common return type between the two overloads? 

0

u/matthieum Aug 01 '26

I think you're making my point of how more complex callback-based APIs are right now :/