4 ms·
Anyone care to elaborate on the evils of boost::bind? Maybe from experience? I used boost::bind and boost::function in VC6 code of all places and I thought tha
by astral303 15y ago
Anyone care to elaborate on the evils of boost::bind? Maybe from experience?
I used boost::bind and boost::function in VC6 code of all places and I thought that the resulting code turned out to be pretty decent (I think newer compilers let you use slightly less verbose syntax), and I really liked having the functionality of being able to pre-bind certain arguments. For example, I had a menu item click handler that I was able to bind a call to a unary method, but with different parameters. I thought the resulting code was simpler overall (and easier to refactor).
- asher 15y agoWell IIRC it was a tempting way to replace for-loops with direct list operations ala Python, Ruby etc. But the amount of syntactic noise and cognitive load seemed too much for the added leverage. Our code had sufficient complexity that I didn't want one more oddity (as many would see it) to explain. But for a small team, or a team that's all on the same page, maybe it's good. Sorry to say there's no dramatic story of code explosion here!
- FooBarWidget 15y agoI wouldn't use it for for-loops either, but man, boost::bind is so handy when compiled with boost::function! I used to use function pointers and 'void *userData'. If I wanted to pass additional data to the function then I have to allocate a structure and not forgetting to free it later which resulted in a lot of boilerplate code.