Debugging with STL
Anyone have any easy ways to see what''s in STL containers in a debugger. I use std::vector for dynamic arrays a great deal and it''s a pain to not be able to type MyArray[5] into the debugger and have it show its value like I can with regular arrays. I''m using VC++.net
Jack
one trick i have used to deal with that is assign to a local reference.
Of course, you have to range check the vector, but at least you can easily see the class type''s details
MyClassvector MyClass;MyClass& localRef = MyClass[2];
Of course, you have to range check the vector, but at least you can easily see the class type''s details
Here''s what you can do. A vector should store the pointer to its first element. Expand the vector contents in Variables window and drag the first element pointer over to the watch window. Then you can add ''+1'', ''+5'' etc. to the expression to watch the respective elements. This works for me in MSVC6.
It''s pretty horrible to get STL working correctly in the debugger. Often you need to know the container internal structure.
ie. cont._First to see the container data.
Search the public.microsoft.vc newsgroup on debugging STL. Answers are there
ie. cont._First to see the container data.
Search the public.microsoft.vc newsgroup on debugging STL. Answers are there
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement