J
James Aguilar
Hey all, I have a quick question with FAQ 10.18. I was running into a
problem similar to this yesterday, fortunately, Victor Bazarov helped me out
there. I do have a question about the way the compiler interprets this
line, the workaround for the problem of using a temporary in a constructor:
Foo x = Foo(Bar());
My question is, what exactly does this do? Do is create a default
constructed Foo and then overwrite it using the assignment operator with
whatever is on the right side? Or does it simply initialize a Foo object
with whatever is on the right side? Can I count on this to happen the same
way everywhere? Lastly, is there any way that this pattern of using
assignment can hurt me silently (i.e. performance-wise or any other way)?
Sorry if the question seems obscure or useless. It's just that I plan on
doing this for a long time, and I'd like to know now how I need to proceed
so I don't shoot myself in the foot later. =)
- JFA
problem similar to this yesterday, fortunately, Victor Bazarov helped me out
there. I do have a question about the way the compiler interprets this
line, the workaround for the problem of using a temporary in a constructor:
Foo x = Foo(Bar());
My question is, what exactly does this do? Do is create a default
constructed Foo and then overwrite it using the assignment operator with
whatever is on the right side? Or does it simply initialize a Foo object
with whatever is on the right side? Can I count on this to happen the same
way everywhere? Lastly, is there any way that this pattern of using
assignment can hurt me silently (i.e. performance-wise or any other way)?
Sorry if the question seems obscure or useless. It's just that I plan on
doing this for a long time, and I'd like to know now how I need to proceed
so I don't shoot myself in the foot later. =)
- JFA