I would like to find the size of a boost::unordered_map I have that contains a pointer to a class mapped by a std::string. I am doing a sizeof(unordered_map var). Is that right? Would it give me the space it occupies? Including the house keeping it takes up? Wanted to measure it to compare it to a std::map that will hold the same data, which also I would measure by sizeof(std::map var). I would like to know both to decide how much storage each occupies, and which is a better alternative to go with, comparing the speed and space.
Please let me know if my way of calculating the sizes are right and will give me the actual/correct sizes and will help me make the right decision.
Edit 1:
If my way of trying to get the size is wrong, please let me know ways of getting the correct size(inclusive of house keeping)
TIA
-R
You're simply not going to be able to reliably calculate the amount of space used up by your map. There's types and space you have no access to.
What you should do is ask a totally different question having to do with the problem you're trying to solve where you think this is necessary.