title: How to use pass-by-reference arguments of template type in method templates?
body: <p>I am currently struggling to get the following code to compile. First the header file containing a class with a method template:</p>
  
  <pre><code>// ConfigurationContext.h
  
  class ConfigurationContext
  {
      public:
      template&lt;typename T&gt; T getValue(const std::string&amp; name, T&amp; default) const
          {
              ...
          }
  }
  </code></pre>
  
  <p>Somewhere else I want to call this method like this:</p>
  
  <pre><code>int value = context.getValue&lt;int&gt;("foo", 5);
  </code></pre>
  
  <p>There I get the following error:</p>
  
  <pre><code>error: no matching function for call to 'ConfigurationContext::getValue(const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;, int)'
  </code></pre>
  
  <p>I checked the obvious errors like missing includes and stuff like that. But everything seems to be right. I tried removing the pass-by-reference of the template type argument like this:</p>
  
  <pre><code>template&lt;typename T&gt; T getValue(const std::string&amp; name, T default) const ...
  </code></pre>
  
  <p>Then it compiles without any errors and also runs fine, but I'd still like to pass in a reference here...</p>
  
  <p>Does anybody know whats happening here and how to make this work?</p>