How to convert c++ std::list element to multimap iterator
Hello all
i have
std::list<multimap<std::string,std::string>::iterator> >
now i have new element :
multimap<std::string,std::string>::value_type aNewMmapValue("foo1","test")
i want to avoid the need to set temp multimap and do insert to the new element just to get its iterator back
so i could to push it back to the:
std::list<multimap<std::string,std::string>::iterator> >
can i somehow avoid this creation of the temp multimap.
Re: How to convert c++ std::list element to multimap iterator
If you are storing a list of multimap iterators, then the original values MUST exist in a multimap somewhere, otherwise the iterator to it will be invalid.
Also be aware that if the multimap should re-assign it's internal storage then all of your iterators in the list will be invalidated.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Re: How to convert c++ std::list element to multimap iterator
Originally Posted by umen
Hello all
i have
std::list<multimap<std::string,std::string>::iterator> >
now i have new element :
multimap<std::string,std::string>::value_type aNewMmapValue("foo1","test")
i want to avoid the need to set temp multimap and do insert to the new element just to get its iterator back
so i could to push it back to the:
std::list<multimap<std::string,std::string>::iterator> >
can i somehow avoid this creation of the temp multimap.
I'm trying to understand the reason behind you trying to convert an iterator in the first place.
If you recall, map::insert() that takes a single argument of value_type() returns a pair,
so you can do something like
without creating a temp map, so there's no need for conversion here.
But I could be totally wrong about what you're asking here.
If this was way off,
then maybe use std:air? (I haven't tried it yet) to make a bridge?
or something like that...
Bookmarks