Suppose I have a std::vector
say Vector
Now after performing some operations on the vector(either insertion or deletion) I want to check if the vector is empty and on the basis of that I want to perform some operations.
Which approach is better
Approach 1
if (Vector.size() == 0){ /* operations */ }
Approach 2
if (Vector.empty()) { /* operations */ }
Which is a better approach, 1
or 2
?