Boost logo

Boost Users :

From: pviallet_at_[hidden]
Date: 2005-08-31 08:31:07


I’m just starting to use boost::lambda an boost::lambda::bind, and I do
not understand why this do not work whith bnuy::vector && std::valarray :

class CToto{
public:
       CToto(double _i): a(_i) {}
       CToto(): a(0.0) {}
       double get() const
             {return a;}
private:
        double a;
};

std::vector<std::CToto *> aTotoPtrVect;
aTotoPtrVect.push_back(new std::CToto(1.1));
aTotoPtrVect.push_back(new std::CToto(2.2));
aTotoPtrVect.push_back(new std::CToto(3.3));
aTotoPtrVect.push_back(new std::CToto(4.4));

//case 1
std::vector <double> dv(std::distance((aTotoVect.begin(), aTotoVect.end());
std::for_each(aTotoPtrVect.begin(), aTotoPtrVect.end(),
bll::var(dv)[bll::var(uiIdx)++] = bll::bind(&CToto::get, bll::_1)); //
work fine

//case 2
double d(4)
std::for_each(aTotoPtrVect.begin(), aTotoPtrVect.end(),
bll::var(d)[bll::var(uiIdx)++] = bll::bind(&CToto::get, bll::_1)); // work
fine

//case 3
std::valaray <double> dvv(std::distance((aTotoVect.begin(),
aTotoVect.end());
std::for_each(aTotoPtrVect.begin(), aTotoPtrVect.end(),
bll::var(dvv)[bll::var(uiIdx)++] = bll::bind(&CToto::get, bll::_1)); // do
not compile

//case 4
bnu::vector<double> bvv(std::distance((aTotoVect.begin(), aTotoVect.end());
std::for_each(aTotoPtrVect.begin(), aTotoPtrVect.end(),
bll::var(bvv)[bll::var(uiIdx)++] = bll::bind(&CToto::get, bll::_1)); // do
not compile

Is someone could explain me why it work in 1 and 2 ?


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