Reduce C++ source by variable substitution and dead code truncation?
<p>Suppose I have some template classes with Nontype parameters.</p>

<pre><code>template &lt;int hi, int wid&gt;
class SomeThing {
...
}
</code></pre>

<p>I need to create a tool to reduce this source with given value of <code>hi</code> and <code>wid</code>, say, <code>hi=2; wid=3</code>. Sequentially, there might be some code becomes dead code, and the tool also needs to truncate them away. So, finally I expect to see a reduced source code as the output of the tool. Is there any known way to do this? A harder way may be to create my own c++ parser... sounds terrible even a simplified one.</p>

<p>I know there are tools like gcc-xml and clang which can parse it and give an easy-to-parse intermediate file. However, it looks like that it's not enough for me to regenerate c++ source file from that.</p>

<p>[EDIT]
A whole picture is to create a tool to generate source code from source code, with variable substitution and dead code truncation.</p>
