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 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 ?