title: I Can Define a Templatized Function Within a Lambda in Visual Studio
body: <p>In <a href="https://stackoverflow.com/a/37117023/2642059">this answer</a> I point out that I can define a templatized method within a struct defined in a lambda. gcc gives a compiler error when I try to do this.</p>
  
  <p>To the end of a <a href="https://stackoverflow.com/help/mcve">Minimal, Complete, Verifiable Example</a> I've writen a simpler example case here:</p>
  
  <pre><code>[]{struct{
      template &lt;typename T&gt; foo() { cout &lt;&lt; "default\n"; }
      template &lt;&gt; foo&lt;char&gt; foo() { cout &lt;&lt; "specialized\n"; } } result;
      return result; }
  </code></pre>
  
  <p><a href="http://ideone.com/sJf4Fk" rel="nofollow noreferrer"><kbd>Live Example</kbd></a></p>
  
  <p>This code runs fine in Visual Studio which can be tested at <a href="http://webcompiler.cloudapp.net/" rel="nofollow noreferrer">http://webcompiler.cloudapp.net/</a> but the linked gcc code:</p>
  
  <blockquote>
    <p>Invalid declaration of member template in local class</p>
  </blockquote>