You want vector::size()
and set::size()
.
Assuming v
is your vector, do this:
size_t size = 0;
for (vector<set<char> >::const_iterator cit = v.begin(); cit != v.end(); ++cit) {
size += cit->size();
}
sizeof()
is giving you the in-memory size of the object/type it is applied to, in multiples of sizeof(char)
(usually one byte). If you want to know the in-memory size of the container and its elements, you could do this:
sizeof(v) + sizeof(T) * v.capacity(); // where T is the element type