Problem with std::map
-
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> ]
ykutanoor wrote: m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList); Try
m_SplFileInfoMap.insert(std::make_pair(f_crstrUserID,l_SplFileTSInfoList));
There are other idioms for inserting into maps, I suggest reading around a bit. Paul