I've been reading about C++ containers and iterators. For my question, I think the following observations are relevant:
- UnorderedAssociativeContainer is a Container.
value_typeisstd::pair<const Key, T>.iteratoris LegacyForwardIterator and dereferencing it returns container'svalue_type.
Does this imply that any UnorderedAssociativeContainer must internally store items as value_type?
My curiosity stems from a considering the memory footprint of containers. If I have std::unordered_map<int32_t, int64_t>, then on 64-bit systems std::pair<int32_t, int64_t> will have 32 unused bits due to alignment. I think we should be able to store things more compactly, but I don't see how to satisfy the requirements if the storage is organized in any other way than value_type.
How could iterator return a reference to value_type if the internal storage were organized differently?