Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range] invalid initialization of non-const type with adaptors
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2010-05-10 09:28:50


Neil Groves skrev:
> On Mon, May 10, 2010 at 2:35 AM, Denis Taniguchi <taniguchi_at_[hidden]
> <mailto:taniguchi_at_[hidden]>> 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;
> }
>
> But I get the following erros with gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3:
> Am I missing something here?

We shall ignore that there is no reason to use "reversed" here.

>
> The reason this will not compile is that 'vec |
> boost::adaptors::reversed' returns an unnamed temporary which is then
> attempted to be passed to the fill function. On many versions of Visual
> C++ this actually will compile and work as you intended due to a
> language extension, but this is non-standard.

Does make_reverse_range(rng) not use iterator_range rather than sub_range?

Also, I don't see any reason why a const T& overload of boost::fill
cannot exists as long as the const-iterator is actually a mutable
iterator (like with iterator_range<MutableRange>).

-Thorsten


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