This should be a quite elementary question...
Let a
be a variable of type T
, and f()
be any kind of function which returns T
(or T&
, or anything that can be assigned to T
). Now, assume f()
does not modify a
. Consider:
a = f();
For T
to be a user-defined type, I can be sure that a
will only be modified after the evaluation of f()
has finished. Because a = f();
is a call of the operator=()
function, and the execution will not go into the function body before the argument is evaluated.
For T
to be a built-in type, may I ask if the data in a
is never modified before the evaluation of f()
is finished?
The reason that I would like to confirm this is because I really want to make sure that in any cases where such a f()
throws an exception, we can safely say that the data in a
is not corrupted.