title: How to count function template instantiations
body: <p>Say I have a function template <code>func</code> and it gets instantiated several times with the same template parameter. The individual instances with the same template parameter should be counted  (from 0 on) and the instance count should be accessible from <code>func</code>'s implementation. Clearly, a static member is not what I am searching for. Instead, it looks to me that instance counting needs to be implemented with compile-time type computation.</p>
  
  <p>Example (user code):</p>
  
  <pre><code>{
    for(int i=0;i&lt;10;i++) {
      func&lt;float&gt;();           // This should be instance number 0
    }
    func&lt;float&gt;();             // This should be instance number 1
  }
  </code></pre>
  
  <p>Despite the runtime loop the first instance of <code>func</code> gets the number 0. That is over all loop iterations the instance number should not change. Only when the loop exits and the function is called again, the number should be incremented, namely to 1.</p>
  
  <p>Original template:</p>
  
  <pre><code>template&lt;class T&gt; void func() {}
  </code></pre>
  
  <p>Possible ways to access the instance count:</p>
  
  <pre><code>template&lt;class T,int COUNT&gt; void func() {}   // instance number as template parameter
  template&lt;class T&gt; void func(int count) {}    // or as function argument
  </code></pre>
  
  <p>Can this be done with some fancy call wrapper? If so, how?</p>
  
  <p>I fear it's not possible... But, right now I have a good use for it ..</p>