Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with std::map insert

Problem with std::map insert

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++css
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ykutanoor
    wrote on last edited by
    #1

    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> ]

    J D 2 Replies Last reply
    0
    • Y ykutanoor

      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> ]

      J Offline
      J Offline
      Jens Doose
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • Y ykutanoor

        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> ]

        D Offline
        D Offline
        Dean Goodman
        wrote on last edited by
        #3

        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 try m_SplFileInfoMap.insert(make_pair(f_crstrUserID, l_SplFileTSInfoList)); --Dean

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups