C++Now 2018: Marcel Ebmer “for_each_adjacent<N>”

preview_player
Показать описание

Lightning Talk


---

*--*

---
Рекомендации по теме
Комментарии
Автор

wouldn't it make more sense to have an "adjacent_iterator<N>" and simply use it with all the regular algorithms?

AxelStrem
Автор

Hmm.. thinking about the new ranges, it looks like you're after some transform that takes the first range and gives you a bunch of sub-ranges of n consecutive items.
It's a bit like a sliding-window range adaptor, could be really useful for convolutions!

Dth
Автор

Why even bother with tuple<T>, if you can use array<T, N>?

ashvardanian
Автор

As it was mentioned, your version is not terribly nice for forward_iterators.

However, the std::next(first, Is) trick is really cool and it will be faster for random access (just replace the container type and give it more arguments to work on).
Really nit trick.

Maybe passing adjacent elements as a range would be better though.

denisyaroshevskiy
Автор

Why not deduce the arity of the function and use it instead of explicit N.

Voy
Автор

Meh. Weird approach. Create an iterator that consumes in N-ary chunks, then you can use all the algorithms...

karolyhorvath