6 comments

[ 3.1 ms ] story [ 27.9 ms ] thread
C++ was so much cleaner in the 90s, when it was still essentially "C with classes," which is how I like to use the language. Modern standards have turned it into an ugly mess.
Red flags for me when I see nonstandard functors in a c++ codebase (esp if the "glue" is in a setup function independent of the objects):

(i) Have they thought about the relative lifetimes of the sender and receiver?

(ii) Is the callback a "critical section" where certain side-effects have undefined behavior?

(iii) Does the functors store debugging info that .natvis can use?

(iv) Is it reeeeeeeally that bad to just implement an interface?

not sure why the title was renamed, but i thought this was interesting primarily because it's the early work of Rich Hickey, famous for making the Clojure language.
Doing this today I'd just have a std::function parameter and have callers pass in a lambda. I may use a third party std::function that doesn't have the weird copy semantics though