Opened 12 years ago

Closed 11 years ago

#4832 closed Feature Requests (worksforme)

C++0x lambdas do not work as argument to Boost::Range's transformed adaptor

Reported by: Alexander Bessonov <alexbav@…> Owned by: Douglas Gregor
Milestone: To Be Determined Component: utility
Version: Boost Development Trunk Severity: Problem
Keywords: c++0x lambda transformed boost::range Cc:

Description

You cannot use lambda functions as parameters to transformed adaptor. At least on Visual Studio 2010.

This is due to native inability to take a result_of the lambda function.

A simple workaround for Visual Studio 2010 is offered (see attached patch for trunk 66478). If it is applied and checked to work on other compilers, please update.

Attachments (1)

lambda.patch (1.2 KB ) - added by Alexander Bessonov <alexbav@…> 12 years ago.
patch for boost/utility/result_of.hpp

Download all attachments as: .zip

Change History (6)

by Alexander Bessonov <alexbav@…>, 12 years ago

Attachment: lambda.patch added

patch for boost/utility/result_of.hpp

comment:1 by Alexander Bessonov <alexbav@…>, 12 years ago

Version: Boost 1.44.0Boost Development Trunk

comment:2 by Neil Groves, 12 years ago

Component: rangeutility
Owner: changed from Neil Groves to Douglas Gregor

I have recently reaalized the solution requires a modification to result_of rather than a change to Boost.Range.

in reply to:  2 comment:3 by Alexander Bessonov <alexbav@…>, 12 years ago

Replying to neilgroves:

I have recently reaalized the solution requires a modification to result_of rather than a change to Boost.Range.

Agree. It seems that range lib in trunk started to use boost's result_of (compared to its own implementation in 1.44). My patch addresses variant with a single argument for VC 2010 and needs to be extended for multiple arguments using standard "preprocessor magic". If I get a working variant for multiple arguments, I will update the ticket.

comment:4 by Steven Watanabe, 12 years ago

If the compiler has decltype, most of the logic in result_of is unnecessary.

comment:5 by Michel MORIN <mimomorin@…>, 11 years ago

Resolution: worksforme
Status: newclosed

With BOOST_RESULT_OF_USE_DECLTYPE, boost::result_of and C++0x lambdas work fine. Please see the documentation for usage of BOOST_RESULT_OF_USE_DECLTYPE: http://www.boost.org/doc/libs/1_47_0/libs/utility/utility.htm#result_of

(On Visual Studio 2010, using BOOST_RESULT_OF_USE_DECLTYPE works fine with Boost 1.47 and trunk. But it might not work with older versions of Boost, since BOOST_NO_DECLTYPE is defined for that compiler. )

Note: See TracTickets for help on using tickets.