```std::count()``` should be as fast as it gets without storing the value. I'll like this solution because that way I don't need to keep book of the values. But you are right, if it is too slow we should store the size directly.
I'll try to find out more ....