```
for (auto& x : f().things()) { // dangling reference!
mutate(&x);
}
```
Oh shit I think I have to go through a dozen projects in production and fix some code now. Thanks Herb.
for (auto& x : f().things()) { // dangling reference!
mutate(&x);
}
```
Oh shit I think I have to go through a dozen projects in production and fix some code now. Thanks Herb.
[1] https://stackoverflow.com/questions/21861148/what-does-the-s...
If f() returns a value then you have a problem and should fix it, but if f() instead returns a reference (that is not dangling in itself), then it should be fine.
Now it all makes sense. This is what I get for trying to read technical stuff while drunk at midnight.