title: compile time loops
body: <p>I would like to know if it is possible to have sort of compile time loops.<br>
  For example, I have the following templated class:</p>
  
  <pre><code>template&lt;class C, int T=10, int B=10&gt;
  class CountSketch
  {
  public:
      CountSketch()
      {   
           hashfuncs[0] = &amp;CountSketch&lt;C&gt;::hash&lt;0&gt;;
           hashfuncs[1] = &amp;CountSketch&lt;C&gt;::hash&lt;1&gt;;
           // ... for all i until i==T which is known at compile time
      };
  private:
      template&lt;int offset&gt;
      size_t hash(C &amp;c)
      {
          return (reinterpret_cast&lt;int&gt;(&amp;c)+offset)%B;
      }
      size_t (CountSketch::*hashfuncs[T])(C &amp;c);
  };
  </code></pre>
  
  <p>I would thus like to know if I can do a loop to initialize the T hash functions using a loop. The bounds of the loops are known at compile time, so, in principle, I don't see any reason why it couldn't be done (especially since it works if I unroll the loop manually).</p>
  
  <p>Of course, in this specific example, I could just have made a single hash function with 2 parameters (although it would be less efficient I guess). I am thus <em>not interested in solving this specific problem</em>, but rather knowing if "compile time loops" existed for similar cases.</p>
  
  <p>Thanks!</p>