Boost logo

Boost Users :

From: tom gee (rockonedge_at_[hidden])
Date: 2005-01-16 22:21:13


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<ONE_RECORD> m_v;

private:
    void FillOneLine(const ONE_RECORD& one_line);
    void FillAllLines();
};

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:

e:\Boost\include\boost-1_32\boost\bind.hpp(285): error C2664: 'R
boost::_mfi::mf1<R,T,A1>::operator ()<A>(U & ,A1) const' : cannot
convert parameter 2 from 'boost::arg<I>' to 'A::ONE_RECORD'
        with
        [
            R=void,
            T=A,
            A1=A::ONE_RECORD,
            U=A *
        ]
        and
        [
            I=1
        ]
 Can any body help to explain why and give a solution? Thanks.


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