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. string, map STL problem

string, map STL problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharphelpcssvisual-studio
4 Posts 4 Posters 1 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.
  • M Offline
    M Offline
    Matthew Fleming
    wrote on last edited by
    #1

    Netmeisters, I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value. #include #include #include using namespace std; mapslips; Then to add a pair to the map: string str; pair::iterator, bool> ret = slips.insert(map::value_type(str,report)); But this produces a host of error messages that I've included below. Can't figure these out at all. When I comment out the pair &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const' with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled with [ _Kty=std::string, _Ty=CReport, _Pr=std::less, _Alloc=std::allocator>, _Mfl=false ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\

    B J R 3 Replies Last reply
    0
    • M Matthew Fleming

      Netmeisters, I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value. #include #include #include using namespace std; mapslips; Then to add a pair to the map: string str; pair::iterator, bool> ret = slips.insert(map::value_type(str,report)); But this produces a host of error messages that I've included below. Can't figure these out at all. When I comment out the pair &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const' with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled with [ _Kty=std::string, _Ty=CReport, _Pr=std::less, _Alloc=std::allocator>, _Mfl=false ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\

      B Offline
      B Offline
      Ben Burnett
      wrote on last edited by
      #2

      It compiles fine for me, are you sure it's not some other thing that is causing the trouble? Maybe post some of the code surrounding this snippet. cheers, -B

      1 Reply Last reply
      0
      • M Matthew Fleming

        Netmeisters, I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value. #include #include #include using namespace std; mapslips; Then to add a pair to the map: string str; pair::iterator, bool> ret = slips.insert(map::value_type(str,report)); But this produces a host of error messages that I've included below. Can't figure these out at all. When I comment out the pair &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const' with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled with [ _Kty=std::string, _Ty=CReport, _Pr=std::less, _Alloc=std::allocator>, _Mfl=false ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        For extracting the essence out of these weired error-messages, you can try using STLError Decryptor[^] For me, it works fine - and it is free:)


        My opinions may have changed, but not the fact that I am right.

        1 Reply Last reply
        0
        • M Matthew Fleming

          Netmeisters, I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value. #include #include #include using namespace std; mapslips; Then to add a pair to the map: string str; pair::iterator, bool> ret = slips.insert(map::value_type(str,report)); But this produces a host of error messages that I've included below. Can't figure these out at all. When I comment out the pair &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const' with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled with [ _Ty=std::string ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled with [ _Kty=std::string, _Ty=CReport, _Pr=std::less, _Alloc=std::allocator>, _Mfl=false ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] c:\

          R Offline
          R Offline
          richard_k
          wrote on last edited by
          #4

          You must make sure you have an #include <string> in your source file. Frequently you'll get things to compile with the declarations looking fine, but when usages start if the actual include isn't there then the compiler doesn't know what to do. I think this is being caused by the underlying compiler mechanics of how it instantiates templates.

          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