Steven T. Hatton wrote:
If I understand correctly, a template is translated into its source
equivalence, either explicitly, or implicitly. It seems to me, a tool that
would show me that intermediate form of the template would be very useful
in understanding what my templates are actually doing. Is there such a
tool?
G++ may support this, but I didn't see a way to do it when I looked in the
documentaton. I'll ask on a gcc newsgroup and see if I can get an answer
about that specific issue.
I don't know of such a tool. But how would it be "very useful"? What
in the template code don't you see that the tool would show you? The
actual types? Write your template so that the type argument is named
as one of the supported types, say 'CHAR' for 'char' or 'INT' for 'int'.
It'll be quite readable (better than 'T'). The actual values? Well,
the same solution could work: name the values _1 and _0 or something
like it. Or do you need to see recursive template expansion to see what
happens when you do
template<int _1> class S { blah S<_1 - 1>; };
template<> class S<0> { blahblah; };
? Well, that's a bit tricky. I, for one, would only use that "template
viewing tool" to see the expanded recursive templates. However, I would
be very surprised if such tool would be provided by a company who doesn't
have a compiler because rules concerning templates are complicated and if
you can get them right, you're more than half-way in writing a compiler.
OTOH, if you have enough people to write a compiler, that's what your
efforts would be concentrated on... IMHO.
V