HACKER Q&A
📣 mardiyah

Any tool to look C++ interpretation template form syntax to substitution


Is there please, any tool to have/look c++ interpretation from a template form syntax to its expansion/substitution before it really gets compiled to object/binary ?


  👤 tlb Accepted Answer ✓
Try https://cppinsights.io. For example, go to https://cppinsights.io/s/8401262a and click the play button at the top left.

If you're doing something more complex, you might need metashell. See http://metashell.org/manual/how_to/index.html#see-what-templ.... But you have to really, deeply, love C++ to get much out of it.


👤 dswilkerson
We wrote a C++ front-end from scratch that is quite de-constructed. For example, it will show you the parse tree before type disambiguation. You can visit the templates, or the templates instantiated. It has not been maintained for a while, but here it is:

main page: http://dsw.users.sonic.net/oink/index.html

github repo: https://github.com/dsw/oink-stack/


👤 AlbertoGP
I seem to remember having used some GCC options to look at the expanded templates years ago, but I’m not certain about the details and my impression was that it did not help much.

Trying to verify that I found this tool called Templator that apparently does it in a nice graphical way: https://www.cevelop.com/#templator

The license is restrictive but you can download it for free: https://www.cevelop.com/license/