There is a typo in your last example, it's push_back not push_item.
Once the typo is fixed, that example generates a compiler warning which is hopefully treated as an error. std::vector::size() returns a size_type (size_t) that is unsigned, while int is a signed type. Comparing differently signed ints is error-prone, hence the warning/error.
I'd like to add two comments.
push_backnotpush_item.std::vector::size()returns asize_type(size_t) that is unsigned, whileintis a signed type. Comparing differently signedints is error-prone, hence the warning/error.Appreciate your comment Sandor. Let me update