4 ms·
Ask HN: 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 ?
- AlbertoGP 4y agoI 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 https://www.cevelop.com/#templator The license is restrictive but you can download it for free: https://www.cevelop.com/license/ https://www.cevelop.com/license/
- sargstuff 4y agoclang+ & g++ options for asm & psuedo c/c++ : https://stackoverflow.com/questions/4448094/can-we-see-the-template-instantiated-code-by-c-compiler https://stackoverflow.com/questions/4448094/can-we-see-the-t...
- sargstuff 4y agoCompiler Explorer shows template, expanded template & equivalent assembler. https://godbolt.org/ https://godbolt.org/
- sargstuff 4y agoUntested / unverified approaches: Seems thee's an emacs "expand the C++ template" concept: demystifycpp https://github.com/chriskmanx/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 https://www.jetbrains.com
- sargstuff 4y agoarc [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/ https://arclanguage.github.io/
- tlb 4y agoTry https://cppinsights.io https://cppinsights.io. For example, go to https://cppinsights.io/s/8401262a 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-templates-are-instantiated-by-a-certain-normal-c-expression 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.
- sargstuff 4y agoMetashell & Templator provide a graphical way to display/walk through templight "template code" debugging. https://github.com/mikael-s-persson/templight https://github.com/mikael-s-persson/templight templar : https://github.com/schulmar/Templar/wiki/HowTo https://github.com/schulmar/Templar/wiki/HowTo metashell gui front end : https://kandi.openweaver.com/c++/RangelReale/msgui https://kandi.openweaver.com/c++/RangelReale/msgui
- dswilkerson 4y agoWe 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 http://dsw.users.sonic.net/oink/index.html github repo: https://github.com/dsw/oink-stack/ https://github.com/dsw/oink-stack/