title: Boost.MPL and type list generation
body: <h3>Background</h3>
  <p>This is for a memory manager in a game engine. I have a <code>freelist</code> implemented, and would like to have a compile-time list if these. (A MPL or Fusion vector, for example). The <code>freelist</code>'s correspond to allocation sizes, and when allocating/deallocating objects of size less than a constant, they will go to the corresponding <code>freelist</code>.</p>
  <p>In the end, this means small objects globally have amortized constant time allocation and constant time deallocation. (Yay.)</p>
  <h3>Problem</h3>
  <p>The problem is generating the types I need, so I may eventually use Fusion to instantiate those types. The types in use are (shortened, etc.):</p>
  <pre><code>template &lt;size_t N&gt;
  struct data_block
  {
      size_t mSize; // = N
      char mData[N];
  };
  
  template &lt;typename T, size_t ElementsPerPage,
      template &lt;typename&gt; class Allocator = std::allocator &gt;
  class freelist { /* ... */ };
  
  template &lt;typename T&gt;
  class callocator; // allocator that uses malloc/free
  </code></pre>
  <p>The <code>freelist</code>'s will manage <code>data_block</code>'s of power-of-2 sizes, starting from a minimum going to a maximum. So what I want is:</p>
  <pre><code>static const size_t MinimumSmallSize = 4; // anything smaller gets rounded up
  static const size_t MaximumSmallSize = 512; // anything bigger goes to the large allocator
  static const size_t ElementsPerPage = 4096;
  
  // mpl magic
  </code></pre>
  <p>To generate this:</p>
  <pre><code>typedef boost::mpl::vector&lt;
      freelist&lt;data_block&lt;4&gt;, ElementsPerPage, callocator&gt;,
      freelist&lt;data_block&lt;8&gt;, ElementsPerPage, callocator&gt;
      // ...
      freelist&lt;data_block&lt;256&gt;, ElementsPerPage, callocator&gt;
      freelist&lt;data_block&lt;512&gt;, ElementsPerPage, callocator&gt;
      &gt; free_list_collection;
  </code></pre>
  <p>Obviously, I could do this by hand but I'd rather avoid that for a more general and tweakable interface. Using the Fusion vector in code should be simpler than hard-coded members, too.</p>
  <h3>Question</h3>
  <p>I'm not sure the best way to go about this; I've never used MPL extensively before. Any ideas? I had a few poor ideas such as making a range, then <code>remove_if</code> it's not power of 2, etc., but surely that's not best. Maybe something recursive instead, that doubles each time, pushing into my result vector? I'm not sure how to go about that.</p>