Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2006-02-03 11:34:40


On 2/3/06, Stephen Gross <sgross_at_[hidden]> wrote:
> 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<double(int)> functortype;
functortype f = boost::bind(&Foo::go, _1, 3);

HTH

Stuart Dootson


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net