I recently discovered the ranges stdandard library and encountered a strange behavior. When chaining multiple range adaptors, I can't chain after using std::ranges::views::join
:
vec | std::ranges::views::slide(2) | std::ranges::views::join
works as intended, but
vec | std::ranges::views::slide(2) | std::ranges::views::join | std::ranges::views::slide(2)
will result in compilation error:
error: no match for 'operator|' (operand types are 'std::ranges::join_view<std::ranges::slide_view<std::ranges::ref_view<std::vector<int> > > >' and 'std::ranges::views::__adaptor::_Partial<std::ranges::views::_Slide, int>')
265 | vec | std::ranges::views::slide(2) | std::ranges::views::join | std::ranges::views::slide(2);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | std::ranges::views::__adaptor::_Partial<std::ranges::views::_Slide, int>
| std::ranges::join_view<std::ranges::slide_view<std::ranges::ref_view<std::vector<int> > > >
Why is that? and what do I have to do to make multiple joins work?
Thanks in advance!
std::ranges::views::meow
can be simply written asstd::views::meow
.std::views
is a namespace alias forstd::ranges::views
. – Britney