Boost C++ Libraries: Ticket #5913: Boost.Asio interferes with C++0x-Lambdas having [this]-Capture on MSVC2010 https://svn.boost.org/trac10/ticket/5913 <p> Short Code to reproduce the Problem: </p> <p> #include &lt;boost/asio/io_service.hpp&gt; </p> <div class="wiki-code"><div class="code"><pre><span class="k">struct</span> <span class="n">Data</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">i</span><span class="p">;</span> <span class="p">};</span> <span class="k">struct</span> <span class="n">Foo</span> <span class="p">{</span> <span class="n">Data</span><span class="o">*</span> <span class="n">data</span><span class="p">;</span> <span class="kt">void</span> <span class="nf">bar</span><span class="p">()</span> <span class="p">{</span> <span class="k">auto</span> <span class="n">callback</span> <span class="o">=</span> <span class="p">[</span><span class="k">this</span><span class="p">]()</span> <span class="p">{</span> <span class="n">data</span><span class="o">-&gt;</span><span class="n">i</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="p">};</span> <span class="p">}</span> <span class="p">};</span> </pre></div></div><p> Gives an error on line 10: <code>error C2326: 'void `anonymous-namespace'::&lt;lambda0&gt;::operator ()(void) const': function can not access 'Foo::data' </code> </p> <p> removing the #include fixes the error as well as specifying the access by <code>this-&gt;data-&gt;i = 5;</code> </p> <p> Setup used: MSVC2010 Ultimate with Boost 1.46.1 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5913 Trac 1.4.3 boost@… Mon, 19 Sep 2011 17:11:35 GMT status, severity changed; resolution set https://svn.boost.org/trac10/ticket/5913#comment:1 https://svn.boost.org/trac10/ticket/5913#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> </ul> <p> Ok, I reduced the Problem to the following Code, so it's a MSVC bug: </p> <div class="wiki-code"><div class="code"><pre><span class="k">namespace</span> <span class="n">n1</span> <span class="p">{</span> <span class="k">class</span> <span class="nc">far_away</span> <span class="p">{</span> <span class="k">struct</span> <span class="n">data</span> <span class="p">{};</span> <span class="p">};</span> <span class="p">}</span> <span class="c1">//ns n1</span> <span class="k">namespace</span> <span class="n">n2</span> <span class="p">{</span> <span class="k">struct</span> <span class="n">Data</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">i</span><span class="p">;</span> <span class="p">};</span> <span class="k">struct</span> <span class="n">Foo</span> <span class="p">{</span> <span class="n">Data</span><span class="o">*</span> <span class="n">data</span><span class="p">;</span> <span class="kt">void</span> <span class="nf">bar</span><span class="p">()</span> <span class="p">{</span> <span class="k">auto</span> <span class="n">callback</span> <span class="o">=</span> <span class="p">[</span><span class="k">this</span><span class="p">]()</span> <span class="p">{</span> <span class="n">data</span><span class="o">-&gt;</span><span class="n">i</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="p">};</span> <span class="p">}</span> <span class="p">};</span> <span class="p">}</span> <span class="c1">//ns n2</span> </pre></div></div> Ticket