From 6239357e99af08ded2c532405ee2f6eba6ef8ad9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 20 Feb 2018 21:55:06 +1100 Subject: [PATCH] ranges: Support temporary parameters passed to concatenated --- src/ranges.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ranges.hh b/src/ranges.hh index df622ea5..a67502df 100644 --- a/src/ranges.hh +++ b/src/ranges.hh @@ -263,7 +263,7 @@ struct ConcatView : m_it1(std::move(it1)), m_end1(std::move(end1)), m_it2(std::move(it2)) {} - ValueType operator*() { return is2() ? *m_it2 : *m_it1; } + decltype(auto) operator*() { return is2() ? *m_it2 : *m_it1; } Iterator& operator++() { if (is2()) ++m_it2; else ++m_it1; return *this; } Iterator operator++(int) { auto copy = *this; ++*this; return copy; } @@ -293,12 +293,12 @@ struct ConcatView Iterator end() const { return {m_range1.end(), m_range1.end(), m_range2.end()}; } private: - Range1& m_range1; - Range2& m_range2; + Range1 m_range1; + Range2 m_range2; }; template -ConcatView concatenated(Range1&& range1, Range2&& range2) +ConcatView, decay_range> concatenated(Range1&& range1, Range2&& range2) { return {range1, range2}; }