This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

3048. transform_reduce(exec, first1, last1, first2, init) discards execution policy

Section: 29.8.5 [transform.reduce] Status: WP Submitter: Billy Robert O'Neal III Opened: 2017-12-15 Last modified: 2018-03-24

Priority: 0

View all issues with WP status.

Discussion:

Since there exists only one common Effects element for both the parallel and the non-parallel form of transform_reduce without explicit operation parameters, the current specification of a function call std::transform_reduce(exec, first1, last1, first2, init) has the same effect as if the ExecutionPolicy would have been ignored. Presumably this effect is unintended.

[ 2018-01-15 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

[2018-3-17 Adopted in Jacksonville]

Proposed resolution:

This wording is relative to N4713.

  1. Modify 29.8.5 [transform.reduce] as indicated:

    template<class InputIterator1, class InputIterator2, class T>
      T transform_reduce(InputIterator1 first1, InputIterator1 last1,
                         InputIterator2 first2,
                         T init);
    

    -?- Effects: Equivalent to:

    return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
    
    template<class ExecutionPolicy,
             class ForwardIterator1, class ForwardIterator2, class T>
      T transform_reduce(ExecutionPolicy&& exec,
                         ForwardIterator1 first1, ForwardIterator1 last1,
                         ForwardIterator2 first2,
                         T init);
    

    -1- Effects: Equivalent to:

    return transform_reduce(std::forward<ExecutionPolicy>(exec), first1, last1, first2, init, plus<>(), 
    multiplies<>());