[Boost-bugs] [Boost C++ Libraries] #4566: Binding to a class member with lambda::bind() can cause const qualifier mismatch.

Subject: [Boost-bugs] [Boost C++ Libraries] #4566: Binding to a class member with lambda::bind() can cause const qualifier mismatch.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-08-18 17:52:52


#4566: Binding to a class member with lambda::bind() can cause const qualifier
mismatch.
-------------------------------------------------------+--------------------
 Reporter: David Larsson <david.larsson@…> | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: lambda
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
-------------------------------------------------------+--------------------
 The following code (omitting namespaces) would compile correctly in Boost
 1.43.0, but now fails with error
 ''boost/lambda/detail/function_adaptors.hpp(264) : error C2440
 : 'return' : cannot convert from 'const int' to 'int &''':
 {{{
 bind( &pair<int,int>::first, _1 )( make_pair( 1, 0 ) );
 }}}
 The `boost::lambda::bind()` expression creates a function that returns the
 first element of a pair, and then applies this to a `const pair<int,int>`.
 The following will work, because the argument is not constant:
 {{{
 pair<int,int> x(1,0);
 bind( &pair<int,int>::first, _1 )( x );
 }}}

 A workaround for this issue is to specify the return value of `bind()`
 explicitly, but it shouldn't be necessary for this simple case:
 {{{
 bind<int>( &pair<int,int>::first, _1 )( make_pair( 1, 0 ) );
 }}}

 I have tested this on VC8 and VC10 with identical results.

 Thanks for a great library,

 ''/David''

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4566>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC