Problem with std::map insert
-
I have a application that inserts a CString and CList in a std::map; In .h file typedef CList SplFileTSInfoList; typedef std::map tagSplFileInfoMap; tagSplFileInfoMap m_SplFileInfoMap; In .cpp file //A vrialble of type SplFileTSInfoList SplFileTSInfoList *l_SplFileTSInfoList; //Insert the Key and the List in to the Map m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList); But when I compile this I get an error. error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator' with [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ] and [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ]
-
I have a application that inserts a CString and CList in a std::map; In .h file typedef CList SplFileTSInfoList; typedef std::map tagSplFileInfoMap; tagSplFileInfoMap m_SplFileInfoMap; In .cpp file //A vrialble of type SplFileTSInfoList SplFileTSInfoList *l_SplFileTSInfoList; //Insert the Key and the List in to the Map m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList); But when I compile this I get an error. error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator' with [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ] and [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ]
Well, I guess you would like to map a string to a CList. If yes, use this:
typedef CList SplFileTSInfoList; typedef std::map< CString, SplFileTSInfoList > tagSplFileInfoMap; ... m_SplFileInfoMap.insert( tagSplFileInfoMap::value_type( f_crstrUserID, l_SplFileTSInfoList ) );
Jens -
I have a application that inserts a CString and CList in a std::map; In .h file typedef CList SplFileTSInfoList; typedef std::map tagSplFileInfoMap; tagSplFileInfoMap m_SplFileInfoMap; In .cpp file //A vrialble of type SplFileTSInfoList SplFileTSInfoList *l_SplFileTSInfoList; //Insert the Key and the List in to the Map m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList); But when I compile this I get an error. error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator' with [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ] and [ _Traits=std::_Tmap_traits *,std::less,std::allocator *>>,false> ]
Your error is because you aren't calling
insert
properly. I would guess (though it's hard to tell from your code) that you will want to trym_SplFileInfoMap.insert(make_pair(f_crstrUserID, l_SplFileTSInfoList));
--Dean