-6

I mean, I would like to use

std::map<int, int> 

to store my data. both of the key and the value is the integer.

But now once I debug it, I could not tracking the contents of the key and the value from debugger.

I use qt creator to debug it.

But if I switch the key to string that means

std::map<std::string, int> 

the debugger could work correctly, I could check the contents of the key and value.

user2701639
  • 861
  • 2
  • 8
  • 13
  • 1
    Of course you can use `std::map` – πάντα ῥεῖ Jul 21 '14 at 23:32
  • What do you mean by `find the value of key and the value of value`? I can't make any sense of it. What is `value of key`? If you have a Key, then you have it, and you have its value. Do you mean searching the map for a value related to a key? – quetzalcoatl Jul 21 '14 at 23:35
  • I mean I could not keep tracking the contents in key and value from debugger. – user2701639 Jul 21 '14 at 23:36
  • 2
    i think the question is 'my debugger doesnt work nicely with map, can u help me. IN particular I cant lookup entry 5'. I dont know QT so I cant answer – pm100 Jul 21 '14 at 23:49

1 Answers1

4

The types of the key and value of a map are non-exclusive, i.e.: Using a type on a key does not make that type forbidden in the value, and vice-versa. What's causing your problem is probably an issue with qt-creator and the debugger you're using. You might want to try these:

  • If you're using MinGW 4.8, it uses by default a newer format for storing debugging information. Check if you're using gdb 7.5 or higher. If not, update it.
  • If the above doesn't work, try updating Qt-Creator itself. Older versions are known to have problems with newer versions of GDB.

If none of these work, you might try to downgrade your MinGW version to 4.7 and use a smaller version of gdb. I would only recommend this, though, if you must use such a feature in this specific way.

Not a real meerkat
  • 5,604
  • 1
  • 24
  • 55