Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-28 12:03:32


As an optimization, it should be possible to detect free and member function
arguments to the constructor of function<> and treat them as though they
were passed with ref(), eliminating the need for dynamic allocations in many
cases. It would be interesting to know if bind() and mem_fn() could be smart
enough to report whether they had bound any data (i.e. had been used for
more than composition), and even more interesting to know if there was some
way to detect that they had been bound to compile-time constants (I actually
don't think that's possible, given that all arguments are passed as regular
function arguments).

One simple approach for function<> to take might be to say that if the
constructor argument is an empty class or a built-in function or member
function, it may be treated as though ref() were applied. That wouldn't
apply the optimization in every possible case, but I think it would in most
of them.

Finally, I thought it might be cute if data member pointers would be treated
as accessor functions by function/bind/mem_fn. Just a crazy idea...

-Dave

===================================================
  David Abrahams, C++ library designer for hire
 resume: http://users.rcn.com/abrahams/resume.html

        C++ Booster (http://www.boost.org)
          email: david.abrahams_at_[hidden]
===================================================


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