|
Boost Users : |
Subject: Re: [Boost-users] Boost.Ranges 2.0 algorithms accepting a const reference
From: Neil Groves (neil_at_[hidden])
Date: 2010-07-10 15:33:23
> This is in contrast with the "Introduction" section of the documentation
> which
> stresss that both versions of find have to be implemented due to the
> forwarding
> problem.
>
>
You are entirely correct. The reverse function is missing the const
overload, and this will cause a problem when returning a temporary to a
constant range that has mutable elements. A workaround, which I expect you
have already thought of, would be to hold a const reference to the range in
a variable and pass this into reverse.
I shall put a correction into the trunk as soon as possible. I shall also
review all of the algorithm functions for similar mistakes.
I apologize for my oversight and for any inconvenience this has caused.
> Moreover, iterator_range beheaves like stl iterators (and const_iterators,
> depending on the template argument used) and as such a const
> iterator_range<std::vector<double>::iterator> will behave like a mutable
> range
> (and the range_iterator class knows this).
>
> Please notice this is in contrast with the sub_range class (something I
> personally find a bit confusing :P).
>
>
This is deliberately in contrast. The iterator_range class wraps an iterator
to model a Range Concept. The sub_range wraps a Range, or Container while
preserving const-ness of the underlying Range.
Regards,
Neil Groves
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