sorry for double posting, the first message had the wrong subject
[lamda] instead of [lambda].
On May 11, 3:11 am, alfC
Hi,
I usually have function-classes that take two arguments.
class f{ double operator()(double x, double y) const { x*y+y; }
};
called as:
f myf; cout << myf(4.,3.);
for some purposes I need a function of only one variable (parametrized in the first or second argument. So I end up doing:
using boost::function; using namespace boost::lambda; function
myf_at5 = bind(&f::operator(), myf, 5., _1); // myf_at5 is myf(5.,*) So, now I can pass myf_at5 to something that accepts a function of one variable.
root_finder( myf_at5, ...);
since I have access to f I would like to make f smart enough to handle its own binding. Eg.
class f{ ... // same as before function
operator()(double x_value, YYYY y_arg){ return bind( &f::operator(), //maybe needs cast to double(*) (double,double) *this, x_value, y_arg ); } function operator()(XXXX x_arg, double y_value){ return bind( &f::operator(), //maybe needs cast *this, x_arg, y_value ); } };
The question is: What should be the type of XXXX and YYYY?
in such a way that I can just call
root_finder( myf(5., _1) , ... ); or more complicated things like root_finder( myf(5., _1 * 2.), ...);
in other words, myf(5.,_1) is the same as the old bind(&f::operator(), myf, 5., _1);
Thank you, Alfredo answers using other libraries are also accepted :) _______________________________________________ Boost-users mailing list Boost-us...@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Sie haben diese Nachricht erhalten, da Sie der Google Groups-Gruppe Boost Users beigetreten sind. Wenn Sie Nachrichten in dieser Gruppe posten möchten, senden Sie eine E-Mail an boostusers@googlegroups.com. Wenn Sie aus dieser Gruppe austreten möchten, senden Sie eine E-Mail an boostusers+unsubscribe@googlegroups.com. Besuchen Sie die Gruppe unterhttp://groups.google.com/group/boostusers?hl=de, um weitere Optionen zu erhalten.