c++ - Using [] operator with unordered_map in gdb give unresolved operator -


i have c++ code instantiating unordered_map , printing it's values using cout. works fine. but, when try run in gdb , print values of unordered_map, gives me error. below, code snippet:

  std::unordered_map<std::string,int> mymap = {                       { "mars", 3000},                       { "saturn", 60000},                       { "jupiter", 70000 } };      std::cout<< mymap.at("mars");     std::cout<< mymap["mars"]; 

both cout statements above print unordered_map value key "mars". however, when use gdb , try using below statements print value of mymap @ key "mars", errors.

(gdb) print mymap.at("mars") cannot resolve method std::unordered_map<std::basic_string<char,  std::char_traits<char>, std::allocator<char> >, int,  std::hash<std::basic_string<char, std::char_traits<char>,  std::allocator<char> > >, std::equal_to<std::basic_string<char,  std::char_traits<char>, std::allocator<char> > >,  std::allocator<std::pair<std::basic_string<char, std::char_traits<char>,  std::allocator<char> > const, int> > >::at overloaded instance  (gdb) print mymap["mars"] cannot resolve function operator[] overloaded instance 

i not wrong when use gdb.

i have tried using whatis mymap, in gdb, see if mymap present in current context , gives present. also, tried initializing int variable , printing in gdb , prints it. not understand problem unordered_map.

i using below statement generate executable

gsrivas4@titanx01:~/lcode1$ g++ -std=gnu++11 -o0 -g test1.cpp -o test1.out 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -