[Boost][Range] Immutable range
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? Albert
On Sat, Mar 22, 2014 at 10:20 AM, Albert Yiamakis
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/alg... 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
participants (2)
-
Albert Yiamakis
-
Neil Groves