How to pass a member variable with boost::ref() in boost::bind()?

Here is the work around:
class A
{
...
private:
typedef struct _ONE_RECORD_
{
string sGUID;
string sID;
string sName;
string sSupport;
string sModify;
} ONE_RECORD;
vector

tom gee wrote:
void A::FillAllLines() { ... // method 1 for_each(m_v.begin(), m_v.end(), boost::bind(&A::FillOneLine, this,_1)); // OK // method 2 for_each(m_v.begin(), m_v.end(), boost::bind(&A::FillOneLine, this, ref(_1))); // error ... }
Since ONE_RECORD can be large, I prefer to calling bind() as method 2, but, compiled under VC7.1 it generates such an error: [...]
_1 is always a reference to the first argument. You don't need to wrap it with ref().
participants (2)
-
Peter Dimov
-
tom gee