Say I have code:
struct A {int val, string name};
A a{5, "Hello"};
fn(a.val, std::move(a));
Now it looks like I'm reading from a
and also moving from a
on the same line which looks bad as parameter ordering is generally undefined. However, as std::move
is just a cast that should be ok - so I'm not actually reading from a move
d from value.
What happens though if fn
actually takes the second parameter by value:
fn(int first, A second);
In this case a new A
must be constructed from the moved from value a
. Would this start causing issues in my first example? I assume the constructor of the parameter second
may be called before the first parameter a.val
is read?