By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,897 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,897 IT Pros & Developers. It's quick & easy.

A tool to view instantiated templates?

P: n/a
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.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 22 '05 #2

P: n/a
Steven T. Hatton wrote:
If I understand correctly, a template is translated into its source
equivalence, either explicitly, or implicitly. It seems to me that,
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.


C++ template code is more difficult to read, debug and maintain.
I don't know of any tools (g++ or otherwise)
that will help you display the instantiations.
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.