I need to fix some bugs on an older project of mine, and I thought that this is the perfect occasion to refactor some of the code.
I have a map of the following structure:
std::map< std::string, std::map<std::string, myClass*> > ComponentMap;
Somewhere in I need to iterate through some of the underlying sub-maps and I used the following:
for (std::map<std::string, myClass* >::iterator iter = ComponentMap[compNameString].begin(); iter != ComponentMap[compNameString].end(); ++iter)
{
//some code
if (IsComponentOfType(iter, sCOMP_PRINCIPAL))
iter->second->GetComponentValue(date, compName, 00);
//some more code
}
The IsComponentOfType function has the following declaration:
bool IsComponentOfType(const std::map<std::string, myClass* >::iterator & MapIter, const sCOMPONENT_TYPE & Type)
My question is: When I rewrote the for loop as such:
for (auto const& iter: ComponentMap[compNameString])
I got the following compilation error:
IsComponentOfType(const std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const _Kty,_Ty>>>> &,const sCOMPONENT_TYPE &)': cannot convert argument 1 from 'const std::pair<const _Kty,_Ty>' to 'const std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const _Kty,_Ty>>>> &'
Of what type do I need to rewrite the first argument of the function in order to "make" the c++11 syntax work?
Aucun commentaire:
Enregistrer un commentaire