How to watch the objects value in a STL container in VS2003? Such as Vector
-
Hi, all I'm debugging a program which use lots of STL container such as vector, list, etc. in VS2003 and meeting a very boring problem: I can not see the objects values, such as, all int values in a int vector, in VS debug watch window! I can only see the size of a container. I had to print all values one bye one. This is so inconvenient to make my work process slower. Do you have any ideas? Thanks a lot!:) Remy Zhu
-
Hi, all I'm debugging a program which use lots of STL container such as vector, list, etc. in VS2003 and meeting a very boring problem: I can not see the objects values, such as, all int values in a int vector, in VS debug watch window! I can only see the size of a container. I had to print all values one bye one. This is so inconvenient to make my work process slower. Do you have any ideas? Thanks a lot!:) Remy Zhu
If you look at
std::vector
, it has a member_Myfirst
. This points at the data held by thevector
. So, examining_vector_var_._Myfirst[0]
is the same as evaluating_vector_var_[0]
. This definitely works in the Command Window and there's no reason why it shouldn't work in a Watch window. Alternatively, upgrade to VS 2005, as that has debug data visualizers :-) (no, I haven't upgraded either!) -
If you look at
std::vector
, it has a member_Myfirst
. This points at the data held by thevector
. So, examining_vector_var_._Myfirst[0]
is the same as evaluating_vector_var_[0]
. This definitely works in the Command Window and there's no reason why it shouldn't work in a Watch window. Alternatively, upgrade to VS 2005, as that has debug data visualizers :-) (no, I haven't upgraded either!) -
VS2005 does a much better job with showing the contents of
std::vector
andstd::[w]string
. Apparently you can add your own custom visualizers, but I have yet to try this.So I understand... However, we're pretty much stuck with VS2003 (not that I mind too much - I did when we were stuck with VS6!), although I may well sneak a crafty VS2005 onto my PC here :-) We only do native code development here, as I work for a large company, which has a tightly controlled standard Windows build, which doesn't yet include any version of .NET framework. Fortunately, I'm quite happy doing C++.