A tool to view instantiated templates?

Discussion in 'C++' started by Steven T. Hatton, Aug 19, 2004.

  1. 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
     
    Steven T. Hatton, Aug 19, 2004
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Aug 19, 2004
    #2
    1. Advertising

  3. 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.
     
    E. Robert Tisdale, Aug 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dwerdna
    Replies:
    8
    Views:
    535
    dwerdna
    Mar 23, 2005
  2. JKop
    Replies:
    3
    Views:
    492
  3. recover
    Replies:
    2
    Views:
    831
    recover
    Jul 25, 2006
  4. Parthiv Joshi
    Replies:
    1
    Views:
    753
    Samuel L Matzen
    Jul 6, 2004
  5. Varun Tewari
    Replies:
    2
    Views:
    235
    Tobias Müller
    Jan 27, 2013
Loading...

Share This Page