2012R2 illustrates a very real pitfall with the range base for loop that is intuitive for most C++ developers, and a localised solution to this problem could solve a large number of bugs, especially as ranges become more popular.
While we would welcome a more generalised solution to lifetime analysis, it would be a disservice to the C++ community to wait for a perfect general solution, which may not be possible at all, while this specific problem is easily fixed.
This is indeed not so much a problem of lifetime as it is a problem that the source code is translated to something surprising to users by compilers.
Please consider adopting something along the lines of P2012.
2012R2 illustrates a very real pitfall with the range base for loop that is intuitive for most C++ developers, and a localised solution to this problem could solve a large number of bugs, especially as ranges become more popular.
While we would welcome a more generalised solution to lifetime analysis, it would be a disservice to the C++ community to wait for a perfect general solution, which may not be possible at all, while this specific problem is easily fixed.
This is indeed not so much a problem of lifetime as it is a problem that the source code is translated to something surprising to users by compilers.
Please consider adopting something along the lines of P2012.