From Jason Turner
Watch on YouTube

Summary

This episode demonstrates how to create Python-like generators in C++ without using coroutines or std::generate. Jason shows a clever technique using views::iota and views::transform combined with stateful lambdas to create lightweight, efficient generators. He illustrates the approach with a Fibonacci sequence generator that maintains state between calls but requires no heap allocations, resulting in surprisingly clean and efficient generated assembly code.

Resources

Tags