|
|
|
|
|
by GlitchMr
2390 days ago
|
|
The function that calls `new_point`, the value is moved. Similarly, consider the following case. struct Point a = new_point();
struct Point a2 = a;
Assuming `struct Point` has a destructor, this would move `a` into `a2`, and prevent accesses to `a` after `a2` assignment, as `a` is no longer considered to be alive at this point. C++ has a wrong default of cloning instead of moving, but a new language could fix that. |
|
The logic around it is still pretty complicated, since we’re talking about C++.