...
vector<pair<string,double> > wordsWeight;
wordsWeight.clear();
...
I am reading a project's code and I often found that the author create variables like above: it first declares an empty vector and then immediately call clear() on it. If it is empty, why should clear() do anything useful?
Can I safely remove it and similar statements, or there is some usefulness of it?
CodePudding user response:
If it is empty, why should clear() do anything useful?
It doesn't.
Can I safely remove it
Yes.
and similar statements
Depends on details.