title: How does boost::function support template class with different length template parameters
body: <p>I want to use boost preprocessor to declare template classes with different template variable length, basically like what boost::function does.</p>
  
  <pre><code>#if !BOOST_PP_IS_ITERATING
  
  #ifndef D_EXAMPLE_H
  #define D_EXAMPLE_H
  #include &lt;boost/function&gt;
  #include &lt;boost/preprocessor/iteration/iterate.hpp&gt;
  #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 2, "example.h"))
  #include BOOST_PP_ITERATE()
  
  #else
  template&lt;class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), class T)&gt;
  class Example
  {
      boost::function&lt;T, (BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))&gt; func;
  };
  #endif
  </code></pre>
  
  <p>the code above will obviously won't work because it declares the same class with different template variable length in the same header file. What I want to achieve is to include a single file and define classes with different template variable length just like boost::function.</p>
  
  <pre><code>#include "example.h"
  Example&lt;int, int, float&gt; example1;
  Example&lt;double, int&gt; example2;
  </code></pre>
  
  <p>I looked up boost::function's code but I can't figure it out how it works. Any ideas?  </p>