title: Unable to use lambda in initialization list of template in C++
body: <p>I have a class with a std::function constructor parameter. </p>
  
  <pre><code>class ClazzA{
  public:
      ClazzA(function&lt;void()&gt; foo){}
      ClazzA(){
          ClazzA([](){});
      }
  };
  </code></pre>
  
  <p>If I have an instance of this class as a member of another, I have to call constructor in initializer list. I can pass a lambda as an argument, and it is automatically converted:</p>
  
  <pre><code>class ClazzB{
  public:
      ClazzA a;
      ClazzB() :
        // works fine:
        a([](){}){}
  };
  </code></pre>
  
  <p>But if ClazzB is a template, lambda doesn't work:</p>
  
  <pre><code>template&lt;typename T&gt; class ClazzC{
  public:
      ClazzA a;
      //works fine:
      ClazzC(function&lt;void()&gt; foo) : a(foo){}
      //doesn't work:
      ClazzC() :
        //syntax error : ')'
        a([](){})
        //syntax error : '{'
        //unexpected token(s) preceding '{'; skipping apparent function body
        {}
  };
  </code></pre>
  
  <p>The compiler is MSVC++ 2010. I don't understand what I am doing wrong or why this syntax is not supported.</p>
  
  <p>At first ClazzA was a template too, and function was a bit more complex, so I thought it was the problem with templated lambda or something. But after I removed all that code the problem remains.</p>
  
  <p><strong>UPD:</strong> Tried to compile in MinGW G++, it works. Looks like a Visual Studio issue.</p>