I'm trying to view the contents on an std::map using Eclipse CDT, but all I seem to see is a(n infinite?) tree of red-and-black tree nodes.
- Where's the actual data?
- How come CDT doesn't offer some pretty-printed view of the contents of the map?
I'm trying to view the contents on an std::map using Eclipse CDT, but all I seem to see is a(n infinite?) tree of red-and-black tree nodes.
I'm not sure to what extent Eclipse CDT supports this by default right now, but recent versions of GDB can show you a human-friendly visualization of STL containers, including std::map
. You need GCC version 7 or later and then you can say print the_map_name
and it will show you something like this:
std::map with 2 elements = {[1] = 2, [2] = 4}
For more details on that, see here: https://stackoverflow.com/a/15329434/4323
And for some tips on making it work in Eclipse: How to enable gdb pretty printing for C++ STL objects in Eclipse CDT?
When you have a map iterator iter, just type in the Expressions dialog of Eclipse one of these:
iter->first
iter->second
When you just put iter in the watch window, this will not show the first and second... maybe a bug in Eclipse. (sorry for late reply)