Equivalent C++ to Python generator pattern
Clash Royale CLAN TAG #URR8PPP Equivalent C++ to Python generator pattern I've got some example Python code that I need to mimic in C++. I do not require any specific solution (such as co-routine based yield solutions, although they would be acceptable answers as well), I simply need to reproduce the semantics in some manner. This is a basic sequence generator, clearly too large to store a materialized version. def pair_sequence(): for i in range(2**32): for j in range(2**32): yield (i, j) The goal is to maintain two instances of the sequence above, and iterate over them in semi-lockstep, but in chunks. In the example below the first_pass uses the sequence of pairs to initialize the buffer, and the second_pass regenerates the same exact sequence and processes the buffer again. first_pass second_pass def run(): seq1 = pair_sequence() seq2 = pair_sequence() buffer = [0] * 1000 first_pass(seq1, buffer) second_pass(seq2, buffer) ... re...