Boost logo

Boost Users :

Subject: [Boost-users] [Range] invalid initialization of non-const type with adaptors
From: Denis Taniguchi (taniguchi_at_[hidden])
Date: 2010-05-09 21:35:35


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;
}

But I get the following erros with gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3:

test_fill.cpp: In function ‘int main(int, char**)’:
test_fill.cpp:9: error: invalid initialization of non-const reference of
type ‘boost::range_detail::reverse_range<std::vector<int,
std::allocator<int> > >&’ from a temporary of type
‘boost::range_detail::reverse_range<std::vector<int, std::allocator<int>
> >’
/usr/local/include/boost/range/algorithm/fill.hpp:29: error: in passing
argument 1 of ‘ForwardRange& boost::range::fill(ForwardRange&, const
Value&) [with ForwardRange =
boost::range_detail::reverse_range<std::vector<int, std::allocator<int>
> >, Value = int]’

Am I missing something here?

Best regards,

Denis


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