[Home]Boost.Function, Boost.Bind, And Member Functions

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Difference (from revision 1 to current revision) (minor diff)
(The revisions are identical or unavailable.)
This is an example of using boost.function, boost.bind with member functions. One situation this might be useful is when one wants to use a generic numerical algorithm such as Brent's method for root-finding inside a class.

double F1(boost::function<double(double)> f1); // e.g. Brent's method for root-finding

class A {

    double TwoArg?(double x, double y);
    void Compute(double y);

double A::Compute(double y) {

   // 2nd argument of A::TwoArg? binds to y, 1st argument remains open
   boost::function<double(double)> f1 = boost::bind( boost::mem_fn(&A::TwoArg?), this, _1, y);
   return F1(f1);

BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited February 2, 2007 11:01 am (diff)
Disclaimer: This site not officially maintained by Boost Developers