rof_egnar reversed adapter for(auto x:reversed(range))
summary
Describes a reversible range-for adapter that initially keeps references and therefore uses-after-free when fed temporaries; testing counts constructions and destructions to prove temporaries die before loop body sees elements. Uses C++17 class template argument deduction and special-cases initializer_list, then provides an rvalue overload that holds the container by value (moves in) so the temporary lives for the loop. Proposes deleting begin on temporaries to prevent misuse.
AI-written summary · about
related talks
01h 00mC++ Concepts and Ranges
01h 05mC++11 in the Wild: Techniques from a Real Codebase
01h 02mEmbracing Trailing Return Types and `auto` Return SAFELY in Modern C++
01h 01mC++ Object Lifetime: From Start to Finish
58mFrom Iterators to Ranges: The Upcoming Evolution Of the STL
01h 30m50 shades of C++
54mModern Template Techniques
01h 03mThe most valuable values
