Cram std::map into std:vector
-
I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?
-
I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?
I'm not sure what you mean but I quess perhaps something like this:
typedef std::vector<std::map<..., ...> > VectorOfMaps_t;
The "..."s should be filled in with the types you require in the
map
. I have used atypedef
to avoid having to type the huge type name everywhere and for maintainability. "VectorOfMaps_t" is a bad name really because if I changed the type to astd::deque
ofstd::map
's it would become misleading.Steve
-
For some reason, the original post parsed out the std:map of (std::string,uint) and std:vector of (byte).
That's a really bad idea. Are you sure this will really save you time?!?!
Steve
-
I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?
What you're thinking of is called serialization. Look here on CP and MSDN, the topic has been widely covered.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.