Binding to a static member function?
I'm trying to figure out the correct syntax for boost::bind-ing a static member function with some arguments preset. For example: ============================ struct Foo { static double go(int x, int y) { return x + y; } } typedef ... functortype; functortype f = boost::bind(&Foo::go, _1, boost::constant(3)); f(3); ============================ The actual code I have is a little different; I've simplified it as the above example. At compile time, the compiler complains that it can't find a matching call for 'f(3)'. Any ideas? I can post the complete example, obviously, if that's necessary. Is my syntax for the bind statement correct? Thanks in advance, --Steve Stephen Gross Case Western School of Medicine Cleveland, OH "By Grabthar's hammer, by the sons of Worvan, you shall be avenged." - Dr. Lazarus
On 2/3/06, Stephen Gross
I'm trying to figure out the correct syntax for boost::bind-ing a static member function with some arguments preset. For example:
============================ struct Foo { static double go(int x, int y) { return x + y; } }
typedef ... functortype;
functortype f = boost::bind(&Foo::go, _1, boost::constant(3));
f(3); ============================
The actual code I have is a little different; I've simplified it as the above example. At compile time, the compiler complains that it can't find a matching call for 'f(3)'. Any ideas? I can post the complete example, obviously, if that's necessary. Is my syntax for the bind statement correct?
Thanks in advance, --Steve
1. How do you deduce functortype?
2. Something like this (i.e. using Boost.Function to hold the bound
function) is probably easiest (and compiles and links and runs - I've
checked):
typedef boost::function
participants (2)
-
Stephen Gross
-
Stuart Dootson