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

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7748: Allow explicit result_type specification for transformed
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-09-10 20:35:08


#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
Resolution: | Keywords:
---------------------------------------+------------------------
Description changed by viboes:

Old description:

> 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).

New description:

 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#comment:1>
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:14 UTC