title: const references in c++ templates
body: <p>In a C++ template with the generic type T, I can use</p>
  
  <pre><code>const T &amp;
  </code></pre>
  
  <p>to get a reference to a constant T. However, if now T itself is a reference type (like e.g. T = int &amp;), the above term resolves to</p>
  
  <pre><code>int &amp;
  </code></pre>
  
  <p>and not to</p>
  
  <pre><code>const int &amp;
  </code></pre>
  
  <p>which quite makes sense, since any reference itself is always constant. However, is there still a way to require a</p>
  
  <pre><code>const T &amp;
  </code></pre>
  
  <p>if T itself is a reference type?</p>
  
  <p>Edit: sample code to evaluate (g++ compiler):</p>
  
  <pre><code>template &lt;typename T&gt; class TemplateClass
  {
  public:
      void foo(const T &amp;bar) { }
  };
  
  int main()
  {
      TemplateClass&lt;int &amp;&gt; x;
      x.foo(0);   // &lt;-- compile error: no conversion from int to int&amp;
      return 0;
  }
  </code></pre>