9 ms·
This is why the C preprocessor is superior to templates: gcc's "-E" option will show you the preprocessed source file. (I think clang also?) My personal theor
by nix0n 3y ago
This is why the C preprocessor is superior to templates: gcc's "-E" option will show you the preprocessed source file. (I think clang also?)
My personal theory is that compiler authors have not provided a template equivalent, because they are embarrassed about the code that's being produced.
(If you disagree, prove me wrong!)
- gpderetta 3y ago> prove me wrong Template don't "produce code". They get expanded well after parsing. There is no code to be embarrassed for. Also you can ask GCC to dump any intermediate state: https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html.
- nix0n 3y agoIs there a specific "-fdump" that you recommend?
- planede 3y agocppinsights.io shows expanded function templates as explicit specializations. It's built on LLVM, but I don't think that this tool is upstreamed. https://cppinsights.io/lnk?code=dm9pZCBmb28oYXV0bykge30KCnZvaWQgYmFyKCkgeyBmb28oMCk7IH0=&insightsOptions=cpp23&std=cpp23&rev=1.0 https://cppinsights.io/lnk?code=dm9pZCBmb28oYXV0bykge30KCnZv...
- nix0n 3y agoThank you! This is exactly the sort of thing I was looking for. I found the source at https://github.com/andreasfertig/cppinsights https://github.com/andreasfertig/cppinsights