|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-03-22 10:37:25
From: "Terence Wilson" <tez_at_[hidden]>
> Here's a more complete version.
[...]
> Class MyClass
> {
> ...
>
> Public:
> void MyMethod1(long& thing1);
> void MyMethod2(long& thing1, long& thing2);
> }
> // this compiles and works ok
> std::for_each(Vec.begin(), Vec.end(), boost::bind(&MyClass::MyMethod1,
> _1, boost::ref(something1)));
>
> // this gets me a shedload of compilation errors
> std::for_each(Vec.begin(), Vec.end(), boost::bind(&MyClass::MyMethod2,
> _1, _2, boost::ref(something1), boost::ref(something2)));
Drop the _2. MyMethod2 has three parameters: the implicit 'this', thing1,
and thing2, so you need to pass three arguments: _1 (supplied by for_each),
ref(something1) and ref(something2).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk