how to figure out the type of template parameters using VS Debugger?
I am dealing with the heavily templated code and now need to figure out the type of template parameters.
In the following code that I simplified, How could you debug to find out what type each T is depending on main() that will initiate the A with int, double, or any other type.
template <class T> class A // 1 { public: typedef T Type; }; template <class T> class A<T*> // 2 { public: typedef T Type; }; template <class T> class A<T**> // 3 { pbulic: typedef T Type; };
I tried using Watch window but I don't think it can help me know what T's actual type is.
If T is int*, It will be the best for me to see the code in a instatiation form of the templated code that is something that goes like;
class A // 1 { public: typedef int* Type; };
Thanks in advance.
Answers
Maybe I am misunderstanding what you want, but (even in creaky old MSVS 2003) the Watch (or Auto) window does this nicely for me via the "Type" column:
Note that within a program T could take many different types for different instantiations (e.g. I have three just in my little program in the picture), so it doesn't make sense to ask what type T is outside the context of a specific instantiation.
If you are stepping through a method of a templated class, as well as checking the type of this in the Watch window, you can see it in the call stack: