Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lightweight boost::bind

I'm so sick of the pass-callback-data-as-void*-struct anti-pattern. Boost bind solves it nicely, but is an unacceptable dependency. What's a lightweight alternative? How would I write it myself as simply as possible?

like image 573
Dustin Getz Avatar asked Dec 19 '08 15:12

Dustin Getz


2 Answers

First, I question your assertion that it's far too heavy for you to use.

Second, roll your own template, if you need to control the behavior.

Third, if you're afraid of rolling your own template, I question your ability to judge that boost::bind is too heavy for you to use.

like image 121
Matt Cruikshank Avatar answered Nov 04 '22 18:11

Matt Cruikshank


Check out the fast delegate by Don Clugston. It's supposedly the fastest delegate you can find on most current platforms (compiles down to 2 assembly instructions.) Version 1.4+ gains some Boost.Bind compatibility.

like image 7
ididak Avatar answered Nov 04 '22 17:11

ididak