Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range] invalid initialization of non-const type with adaptors
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-05-10 09:16:31


Denis Taniguchi wrote:
> Hi,
>
> I was trying to compile the following simple piece of code:
>
> #include <boost/range/algorithm.hpp>
> #include <boost/range/adaptors.hpp>
>
> #include <vector>
>
> int main(int argc, char *argv[])
> {
> std::vector<int> vec(10);
> boost::fill(vec | boost::adaptors::reversed, 1);
>
> return 0;
> }

Workaround suggestions:

std::vector<int> vec(10);
BOOST_AUTO(vec_reversed, vec | boost::adaptors::reversed);
boost::fill(vec_reversed, 1);

std::vector<int> vec(10);
BOOST_FOREACH(int& i, vec | boost::adaptors::reversed)
   i = 1;

The first one requires certain compilers.


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