Will the line:
actor (2, 3)
actually create an instance of an actor apart from the one being pushed to the actors vector?
Yes. actor(2, 3)
will create a temporary object of type actor
, unless it’s part of an expression that is unevaluated1. In the constructor of this temporary, a copy (of *this
) will be pushed onto the stack (but note once again that in an unevaluated expression the constructor will of course not be called).
At the end of the expression which contains actor(2, 3)
, the temporary will be destroyed. The vector copy will remain untouched.
1 An unevaluated expression is an expression inside a sizeof(…)
, typeid(…)
, decltype(…)
or noexcept(…)
expression.