Expanding template code automatically

I want to develop a program that will help teach/develop/design C++ template meta-programs by visualizing the transformation from meta-program to "plain" C++.

Every template meta-program can be expanded into equivalent C++ that's generated at compile-time. Doing this mentally is often relatively complicated especially with a large candidate set, so my goal is to "trace" the metaprogram's control flow as it works through it's candidate set and evaluates constant expressions.

Common Lisp has (macroexpand), I want the equivalent in C++.

Any ideas for a starting point -- are there any tools (including compilers) that will partially transform a program in this way? Or will I be stuck hacking LLVM? I think I know what the answer is, but it's worth asking.

FWIW I intend to prototype this in Lisp where this functionality is either built-in or easily defined; I'm hoping I can avoid the really complicated part if I apply the idea to C++.

Thanks
Max
Last edited on
> "trace" the metaprogram's control flow as it works through it's candidate set
> and evaluates constant expressions. ... are there any tools?

Metadebugger http://metashell.org/manual/getting_started/index.html#using-the-metadebugger

Caveat: Metashell/MetaDebugger uses the benign LLVM and boost infrastructure, but it itself is cancerous (GPL v3)
Excellent, thanks.

This will be a good starting point.
Topic archived. No new replies allowed.