Opened 12 years ago
Closed 12 years ago
#4962 closed Bugs (fixed)
Return type deduction issue in boost::lambda
| Reported by: | 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 , 12 years ago
comment:2 by , 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 , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
I'm fairly certain that this was caused by result_of support.
comment:4 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.

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