Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-12-05 16:12:20


Michael Marcin:

> I'm trying to make local modifications to bind to improve the code
> generated the compiler I have to use.

...

> tester::value_type test_bind( tester& t, tester::const_reference x )
> {
> return boost::bind( &tester::test, &t, _1 )( x );
> }

I'd start with a code example that is closer to your actual use, as there is
no reason to use bind at all in the above. Typically boost::bind, which is
the inefficient part, is called once, and the (x) call is done multiple
times inside a for_each or similar. You might find the performance adequate
for some uses. There will certainly be cases where boost::bind won't cut it,
but you'd be able to selectively replace just those uses with handwritten
function objects, or even with handwritten loops.

It's not easy to optimize the general boost::bind case while still allowing
the tests to pass; it might be better to write a separate leaner version
that is more limited but still serves the majority of your specific needs.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk