Shallow display of STL containers in Visual Studio debug mode?
I hit the wall taking away my C ++ class. This is a graph of sorts, something like this:
class Graph {
class Node {
std::map<int, Node>::iterator _neighbors[4];
};
std::map<int, Node> _map;
};
Basically, each node keeps track of exactly 4 neighbors, storing iterators to them in the map of the containing class.
The problem is that when I go out to display the contents of the _map in VS2008 while debugging, I get something like this:
- _map
- [0]
first
- second
- _neighbors
- _ptr
first
- second
- _neighbors
- _ptr
first
- second
- _neighbors
...
Apparently, instead of listing the 4 neighbors of a node with index 0 on the map, it lists its first neighbor, then the first neighbor of the first neighbor, then its first neighbor, etc. ad infinity. Also, it does not appear _neighbors
as an array in any way , although it is declared as such.
I found an add-on called VSEDebug that supposedly extended the STL display, but for VS2k3 and I couldn't get it to work in 2k8 (neither binaries nor compiling it).
The immediate window doesn't help much either, as the call attempt _map.operator[]
returns with CXX0058: Error: overloaded operator not found
.
Any ideas how I can get a meaningful display of my map content? Note that I am fairly new to VS in general, so I will probably need detailed instructions. :)
source to share
You can enter the name of the symbol in the command line window - immediate window and start at the pointers to its members. For example, if you are debugging a std :: vector named v and you want to access its element at position 2, enter
* (v._Myfirst + 2)
Of course the _Myfirst member is implementation dependent. But I think you get the idea. (visual studio has some problems with operator permutations)
source to share
You can try your hand at writing a custom renderer if you like, however you can duplicate functionality that already exists. Here's an article that covers the basics:
http://www.virtualdub.org/blog/pivot/entry.php?id=120
If you just want to see all the elements of an array, you can type "_map [0] .second._neighbors, 4" in the quick view to view it as an array of four, but that's not exactly the fastest in the world.
source to share