Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost][Range] Immutable range
From: Neil Groves (neil_at_[hidden])
Date: 2014-03-22 15:15:00


On Sat, Mar 22, 2014 at 10:20 AM, Albert Yiamakis <vkicefire_at_[hidden]>wrote:

> Hello,
>
> As far as I can tell from the documentation, it is not possible to
> create a range with const iterators only. Is this correct? Would it not
> make sense to have such a range that can be used with non-mutating
> algorithms only?
>
>
No this isn't correct. The range algorithms are documented to work with
constant and mutable references to ranges, and the range meta-functions are
explicitly documented as working with const ranges. The non-mutating
algorithms are explicitly listed here:
http://www.boost.org/doc/libs/1_55_0/libs/range/doc/html/range/reference/algorithms/non_mutating.html

The range currently wraps pairs of iterators. It is not necessary to say if
the iterator is a constant iterator. The meta-function determines the
reference type. For range_reference<const Range>::type where Range, for
example, a standard container will return a constant reference as you would
expect.

> Albert
>

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