Lazy and Proud: How I Failed to Standardize lazy_counted_iterator
summary
Proposal P2406 aims to fix a concrete bug: mainstream implementations of counted_iterator unconditionally increment the wrapped iterator after decrementing the count, which causes infinite loops with filtered ranges and loses one element with input iterators (observed while generating 11 truncatable primes). The paper implements a new lazy_counted_iterator that skips the final increment, goes through five revisions and SG9 review, but the committee rejects replacing counted_iterator; the new adapter idea wins instead.
AI-written summary · about
chapters (11)
- 0:00Introduction and motivation
- 3:22What are C++20 ranges
- 7:09Project Euler problem and bug discovery
- 10:25Standardization process overview
- 13:39WG21 and ISO standardization
- 17:55First paper submission and issues
- 20:51Lazy counted iterator idea emerges
- 23:00Revision one and design challenges
- 25:13SG9 discussions and alternatives
- 27:27ABI break and final revisions
- 29:42Solution and standardization outcome
