From a6fd70c456935b47230b4de297e67d9e02bc85bc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 28 Feb 2018 15:15:51 +1100 Subject: [PATCH] Ranges: Fix copiability of some range view iterators Some iterators were refering to to their view with a const ref, this was making them non-copiable. Change those const ref into const pointers in order to fix that. --- src/ranges.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ranges.hh b/src/ranges.hh index a67502dfc..d39715c07 100644 --- a/src/ranges.hh +++ b/src/ranges.hh @@ -64,7 +64,7 @@ struct FilterView typename std::iterator_traits::value_type> { Iterator(const FilterView& view, RangeIt it, RangeIt end) - : m_it{std::move(it)}, m_end{std::move(end)}, m_view{view} + : m_it{std::move(it)}, m_end{std::move(end)}, m_view{&view} { do_filter(); } @@ -88,13 +88,13 @@ struct FilterView private: void do_filter() { - while (m_it != m_end and not m_view.m_filter(*m_it)) + while (m_it != m_end and not m_view->m_filter(*m_it)) ++m_it; } RangeIt m_it; RangeIt m_end; - const FilterView& m_view; + const FilterView* m_view; }; Iterator begin() const { return {*this, std::begin(m_range), std::end(m_range)}; } @@ -122,9 +122,9 @@ struct TransformView struct Iterator : std::iterator> { Iterator(const TransformView& view, RangeIt it) - : m_it{std::move(it)}, m_view{view} {} + : m_it{std::move(it)}, m_view{&view} {} - decltype(auto) operator*() { return m_view.m_transform(*m_it); } + decltype(auto) operator*() { return m_view->m_transform(*m_it); } Iterator& operator++() { ++m_it; return *this; } Iterator operator++(int) { auto copy = *this; ++m_it; return copy; } @@ -142,7 +142,7 @@ struct TransformView private: RangeIt m_it; - const TransformView& m_view; + const TransformView* m_view; }; Iterator begin() const { return {*this, std::begin(m_range)}; }