Opened 10 years ago
Last modified 9 years ago
#7748 closed Feature Requests
Allow explicit result_type specification for transformed — at Version 1
Reported by: | Owned by: | Neil Groves | |
---|---|---|---|
Milestone: | To Be Determined | Component: | range |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
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).
Change History (2)
by , 10 years ago
Attachment: | range.diff added |
---|
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
patch for proposed syntax