how this statement work ?

Hi,everybody watching my topic.
I read the Effective STL book and encounter an a statement like this below

vector<Contestant>(contestants).swap(contestants);

and the book says
The expression vector<Contestant>(contestants) creates a temporary vector that is a
copy of contestants: vector's copy constructor does the work.
......
At that point (the end of the statement), the temporary
vector is destroyed, thus freeing the memory formerly used by contestants. Voila! Shrink-to-fit.

so my question is how do i know(or guarantee) the temporary vector is freed, is there any sign of it, or it is freed just because it is a anonymous vector with no explicit variable referring to it.

Plus,statements like this is fuzzy to me ,kind of resource-leaky.

Thanks in advance!
That is the compilers job.
well,if that is true, i must get used to it although it might take some time!
Its true. The compiler crated the temporary and the compiler will destroy it.
Topic archived. No new replies allowed.