|
|
|
|
|
by 72deluxe
75 days ago
|
|
So how would you ensure you can't do this? A = 0;
B = 0;
A = move(B);
++B;
++A; What should happen at ++B, and what should A be at the end? How would the compiler enforce this? I can see this being complicated. The compiler can forget about it, but the code doesn't, so you mismatch between what is on screen and what the compiler does, which seems even more confusing. |
|
A quick dirty hack would be to have a static analyzer drop B from the symbol table after it sees std::move and give a warning, but that obviously wont catch other references to it, but maybe it will catch the low hanging fruit.