vector decoy;
void clear_decoy() {
decoy.clear();
vector (decoy).swap(decoy);
}
In the above method
I've never seen that form before.
I have seen it written as:
vector().swap(decoy);
Which means "create a new empty vector, and swap it with the existing one.
vector
To understand that, break in to parts.
vector create a new vector (with it's contents copied from the now empty decoy). The new vector is an anonomous temporary, so let's pretent it's name is newvector.
newVector.swap(decoy); swaps the new vector with decopy.
(Updated per comments to fix bug)