Boost C++ Libraries: Ticket #4566: Binding to a class member with lambda::bind() can cause const qualifier mismatch. https://svn.boost.org/trac10/ticket/4566 <p> The following code (omitting namespaces) would compile correctly in Boost 1.43.0, but now fails with error <em>boost/lambda/detail/function_adaptors.hpp(264) : error C2440 : 'return' : cannot convert from 'const int' to 'int &amp;<strong>: </strong></em></p> <pre class="wiki">bind( &amp;pair&lt;int,int&gt;::first, _1 )( make_pair( 1, 0 ) ); </pre><p> The <code>boost::lambda::bind()</code> expression creates a function that returns the first element of a pair, and then applies this to a <code>const pair&lt;int,int&gt;</code>. The following will work, because the argument is not constant: </p> <pre class="wiki">pair&lt;int,int&gt; x(1,0); bind( &amp;pair&lt;int,int&gt;::first, _1 )( x ); </pre><p> A workaround for this issue is to specify the return value of <code>bind()</code> explicitly, but it shouldn't be necessary for this simple case: </p> <pre class="wiki">bind&lt;int&gt;( &amp;pair&lt;int,int&gt;::first, _1 )( make_pair( 1, 0 ) ); </pre><p> I have tested this on VC8 and VC10 with identical results. </p> <p> Thanks for a great library, </p> <p> <em>/David</em> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4566 Trac 1.4.3 David Larsson <david.larsson@…> Wed, 18 Aug 2010 17:53:10 GMT attachment set https://svn.boost.org/trac10/ticket/4566 https://svn.boost.org/trac10/ticket/4566 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lambda.cpp</span> </li> </ul> <p> Repro case </p> Ticket Steven Watanabe Mon, 03 Jan 2011 22:31:27 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4566#comment:1 https://svn.boost.org/trac10/ticket/4566#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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67640" title="Fix return type deduction for pointers to data members. Fixes #4962. ...">[67640]</a>) Fix return type deduction for pointers to data members. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4962" title="#4962: Bugs: Return type deduction issue in boost::lambda (closed: fixed)">#4962</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4566" title="#4566: Bugs: Binding to a class member with lambda::bind() can cause const ... (closed: fixed)">#4566</a>. </p> Ticket anonymous Fri, 28 Nov 2014 18:27:43 GMT <link>https://svn.boost.org/trac10/ticket/4566#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4566#comment:2</guid> <description> <p> +1 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 28 Nov 2014 18:28:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4566#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4566#comment:3</guid> <description> <p> thanks? I correct my boost 1.44 </p> </description> <category>Ticket</category> </item> </channel> </rss>