1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-19 09:21:30 +03:00

ranges: Support temporary parameters passed to concatenated

This commit is contained in:
Maxime Coste 2018-02-20 21:55:06 +11:00
parent 9b5b974397
commit 6239357e99

View File

@ -263,7 +263,7 @@ struct ConcatView
: m_it1(std::move(it1)), m_end1(std::move(end1)), : m_it1(std::move(it1)), m_end1(std::move(end1)),
m_it2(std::move(it2)) {} 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++() { if (is2()) ++m_it2; else ++m_it1; return *this; }
Iterator operator++(int) { auto copy = *this; ++*this; return copy; } 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()}; } Iterator end() const { return {m_range1.end(), m_range1.end(), m_range2.end()}; }
private: private:
Range1& m_range1; Range1 m_range1;
Range2& m_range2; Range2 m_range2;
}; };
template<typename Range1, typename Range2> template<typename Range1, typename Range2>
ConcatView<Range1, Range2> concatenated(Range1&& range1, Range2&& range2) ConcatView<decay_range<Range1>, decay_range<Range2>> concatenated(Range1&& range1, Range2&& range2)
{ {
return {range1, range2}; return {range1, range2};
} }