Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::bond and assignment
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2010-09-17 12:31:44


> Can this be done?
>
> Thanks for help
michi7x7's advice was correct, the code was just missing a '*'.

Below gives a couple ways you could achieve what you want:

#include <boost/iterator/indirect_iterator.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/make_shared.hpp>
#include <vector>

int main()
{
  std::vector<boost::shared_ptr<int> > tmp(5, boost::make_shared<int>(5));

  std::for_each(tmp.begin(), tmp.end(), *boost::lambda::_1 = 0);

  std::fill(boost::make_indirect_iterator(tmp.begin()),
            boost::make_indirect_iterator(tmp.end()), 0);
}

HTH,
Nate


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