[Boost-bugs] [Boost C++ Libraries] #7748: Allow explicit result_type specification for transformed

Subject: [Boost-bugs] [Boost C++ Libraries] #7748: Allow explicit result_type specification for transformed
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-29 03:22:28


#7748: Allow explicit result_type specification for transformed
----------------------------------------------+-----------------------------
 Reporter: nathan.crookston+boost@… | Owner: neilgroves
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
----------------------------------------------+-----------------------------
 Code like the following doesn't work trunk (and released) transformed:

 std::vector<int> myList(...);
 float sum = boost::accumulate(myList | transformed([](int a) { return a *
 5; }), 0.f);

 The following patch & test modifications allow the following syntax:
 float sum = boost::accumulate(myList | transformed<float>([](int a) {
 return a * 5.f; }), 0.f);

 This wouldn't be a problem if result_of used or fell back to decltype, but
 it seems that won't be available for a while. The proposed syntax could
 also be helpful when using transformed with functors whose implementations
 are both unmodifiable and don't follow result_of.

 Patch has been tested with VC10 and compiled with g++ 4.5 (with and
 without -std=c++0x) and clang++ (without c++0x).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7748>
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:11 UTC