I have a vector<set<char> > data structure (transactions database) and I want to know the size of it. When I use sizeof() with each set<char> the size is 24 in spite of the set contains 3, 4 or 5 chars. Later, when I use sizeof() with the vector<set<char> > the size is 12… I suppose this is not the way to know the size of a data structure. Any help?
Thanks.
I have a vector<set<char> > data structure (transactions database) and I want to know
Share
You want
vector::size()andset::size().Assuming
vis your vector, do this:sizeof()is giving you the in-memory size of the object/type it is applied to, in multiples ofsizeof(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