title: .template (dot-template) construction usage
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords">Where and why do I have to put the &ldquo;template&rdquo; and &ldquo;typename&rdquo; keywords?</a>  </p>
  </blockquote>
  
  
  
  <p>I've come across a strange segment of code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;int N&gt;
  struct Collection {
    int data[N];
  
    Collection() {
      for(int i = 0; i &lt; N; ++i) {
        data[i] = 0;
      }
    };
  
    void SetValue(int v) {
      for(int i = 0; i &lt; N; ++i) {
        data[i] = v;
      }
    };
  
    template &lt;int I&gt;
    int GetValue(void) const {
      return data[I];
    };
  };
  
  template &lt;int N, int I&gt;
  void printElement(Collection&lt;N&gt; const &amp; c) {
    std::cout &lt;&lt; c.template GetValue&lt;I&gt;() &lt;&lt; std::endl; /// doesn't compile without ".template"
  }
  
  int main() {
    Collection&lt;10&gt; myc;
    myc.SetValue(5);
    printElement&lt;10, 2&gt;(myc);
    return 0;
  }
  </code></pre>
  
  <p>It is not compiled without <strong>.template</strong> keyword in <em>printElement</em> function. I've never seen this before and I don't understand what is needed for. Trying to remove it, I got a lot of template-related compilation errors. So my question is when such a construction is used? Is it common?</p>