It is usually the largest unsigned type the system has. It is also the type returned by the STL container size() functions, and is a good type to use for the size of containers. That is what you did on line 1 of the code, which is good. Although constexpr is stronger: it's const'ness can't be cast away with const_cast.
It is a member of std, so should be pre-pended with std::
But that generates a warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
So making counter a std::size_t type fixes that.
I would have a different name for the size variable, perhaps counter?