Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Any tool to look C++ interpretation template form syntax to substitution
8 points by mardiyah on Sept 25, 2022 | hide | past | favorite | 8 comments
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 ?



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.


Metashell & Templator provide a graphical way to display/walk through templight "template code" debugging. https://github.com/mikael-s-persson/templight

templar : https://github.com/schulmar/Templar/wiki/HowTo

metashell gui front end : https://kandi.openweaver.com/c++/RangelReale/msgui


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/


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/


clang+ & g++ options for asm & psuedo c/c++ : https://stackoverflow.com/questions/4448094/can-we-see-the-t...


Compiler Explorer shows template, expanded template & equivalent assembler. https://godbolt.org/


Untested / unverified approaches:

Seems thee's an emacs "expand the C++ template" concept: demystifycpp https://github.com/chriskmanx/demystifycpp

etbrain's ide package(s) support gcc cpp directives, so in theory should be able to expand a c++ template in cpp fashion in similar manner as regular code blocks. https://www.jetbrains.com


arc [1] / racket implimentation of demystifycpp might be able to provide something 'usable'/presentable at the command line and/or as a straight up web browser html file.

[1] : https://arclanguage.github.io/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: