for_each_adjacent<N>
summary
Implements a compile‑time sized loop called for_each_adjacent<N> that invokes a callable on each N‑tuple of consecutive elements (works for N=1,2,3 and beyond), uses C++17 features like std::apply and if constexpr to pack N elements into a tuple while preserving references and proxies, and falls back to a much simpler C++14-style implementation using integer_sequence and std::get. The implementation compiles and runs on examples, prints the expected sequences and generalizes adjacent algorithms.
AI-written summary · about
chapters (5)
- 0:00Start
- 1:22for_each_pair v1.0
- 1:57for_each_three
- 2:41for_each_adjacentsN v1.0
- 4:30for_each_adjacent v2.0
related talks
05mMultidimensional Iterators
01h 31mSTL Algorithms – How to Use Them and How to Write Your Own
01h 02mC++20 Ranges in Practice
04mGeneralized fold expressions
01h 25mNew Algorithms in C++23
01h 01mAlgorithm Intuition (part 2 of 2)
01h 09mMissing (and future?) C++ Range Concepts
01h 06mC++20 Ranges in Practice
