3 ms·
The problem is that the pair in the for loop should have a const T as the first parameter. Because it does not have that, you are actually getting a temporary b
by RcouF1uZ4gsC 10y ago
The problem is that the pair in the for loop should have a const T as the first parameter. Because it does not have that, you are actually getting a temporary back and storing a pointer to a temporary in selected.
The fix to avoid this is to use auto. If instead of pair, you used auto&& p: map, this would not be an issue