MapGenerator only calls mapping function if the result is used

Previously the mapping was eager on construction and calls to
`next()`. This was fine when generators were always exhausted fully,
but with the new generator filtering, we might not want to call
the map function eagerly; rather we want to call it only once,
after the generator is moved to the target element.
This commit is contained in:
Martin Hořeňovský
2026-02-15 20:44:21 +01:00
parent 3a0cf7e75f
commit 056e4fe88d
13 changed files with 117 additions and 86 deletions
@@ -709,6 +709,7 @@ TEST_CASE("MapGenerator can be skipped forward efficiently",
};
MapGenerator<int, int, decltype(map_func)> map_generator( map_func, values( { 0, 1, 2, 3, 4, 5, 6 } ) );
REQUIRE( map_calls == 0 );
const int map_calls_1 = map_calls;
map_generator.skipToNthElement( 4 );