Opened 12 years ago

Closed 12 years ago

#4962 closed Bugs (fixed)

Return type deduction issue in boost::lambda

Reported by: pavel.pervov@… Owned by: Steven Watanabe
Milestone: To Be Determined Component: lambda
Version: Boost 1.45.0 Severity: Regression
Keywords: Cc:

Description

The following code stopped compiling after migration from version 1.42 to 1.45 of the library:

#include <algorithm>
#include <map>
#include <string>
#include <iostream>

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>

typedef std::map<int, int> MyMap;

std::ostream& operator << (std::ostream& outs, const MyMap& a)
{
       std::for_each(a.begin(), a.end(),
               outs << boost::lambda::bind(&MyMap::value_type::second, boost::lambda::_1) << "\n");
       return outs;
}

int main()
{
       MyMap a;
       std::cout << a;
}

Change History (4)

comment:1 by pavel.pervov@…, 12 years ago

The workaround for this may be explicit specialisation of boost::lambda::bind with the desired return type:

              outs << boost::lambda::bind<int>(&MyMap::value_type::second, boost::lambda::_1) << "\n");

comment:2 by Marshall Clow, 12 years ago

Compiling with TOT clang, I get (after trimming a long traceback):

In file included from junk.cpp:6:
In file included from /Marshall/Sources/boost/release/boost/lambda/lambda.hpp:14:
In file included from /Marshall/Sources/boost/release/boost/lambda/core.hpp:48:
/Marshall/Sources/boost/release/boost/lambda/detail/function_adaptors.hpp:264:12: 
      error: binding of reference to type 'int' to a value of type 'int const' drops qualifiers
    return o.*data;
           ^~~~~~~

and the workaround suggested by Pavel doesn't seem to help with clang++, btw.

comment:3 by Steven Watanabe, 12 years ago

Owner: changed from No-Maintainer to Steven Watanabe
Status: newassigned

I'm fairly certain that this was caused by result_of support.

comment:4 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: assignedclosed

(In [67640]) Fix return type deduction for pointers to data members. Fixes #4962. Fixes #4566.

Note: See TracTickets for help on using tickets.