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

Problem with std::map

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++css
2 Posts 2 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> ]

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

      P Offline
      P Offline
      Paul Ranson
      wrote on last edited by
      #2

      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

      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