title: building and accessing a list of types at compile time
body: <p>I am trying to achieve the following using c++ template metaprogramming. I wish to build up a list of types and then collect these types together and do further compile-time processing on the list. So for example:</p>
  
  <p>foo.h:</p>
  
  <pre><code>class Foo { ... };
  // INSERT ANY CODE HERE
  </code></pre>
  
  <p>bar.h:</p>
  
  <pre><code>class Bar { ... };
  // INSERT ANY CODE HERE
  </code></pre>
  
  <p>main.h:</p>
  
  <pre><code>#include "foo.h"
  #include "bar.h"
  
  struct list_of_types {
    typedef /* INSERT ANY CODE HERE */ type;
  };
  </code></pre>
  
  <p>I can insert any code into the slots above, so long as list_of_types::type resolves to some representation (e.g. a boost::mpl::vector) of a list containing the types Foo and Bar. The following restrictions apply:</p>
  
  <ol>
  <li><p>The code in foo.h should not know about the code in bar.h, and vice versa. It should be possible to change the order of #include directives in main.h and not change any other code.</p></li>
  <li><p>The code in main.h should not have to change if I include further headers that add further types to the list.</p></li>
  <li><p>The list of types must be available at <em>compile time</em>. I am planning to do further metaprogramming involving the list.</p></li>
  </ol>