Title
Parallel versions of std::copy and std::move shouldn't be in order
Status
c++17
Section
[alg.copy][alg.move]
Submitter
Tim Song

Created on 2016-03-23.00:00:00 last changed 81 months ago

Messages

Date: 2016-05-22.15:38:38

Proposed resolution:

This wording is relative to N4582.

  1. Insert the following paragraphs after [alg.copy]/4:

    template<class ExecutionPolicy, class InputIterator, class OutputIterator>
      OutputIterator copy(ExecutionPolicy&& policy, InputIterator first, InputIterator last,
                          OutputIterator result);
    

    -?- Requires: The ranges [first, last) and [result, result + (last - first)) shall not overlap.

    -?- Effects: Copies elements in the range [first, last) into the range [result, result + (last - first)). For each non-negative integer n < (last - first), performs *(result + n) = *(first + n).

    -?- Returns: result + (last - first).

    -?- Complexity: Exactly last - first assignments.

  2. Insert the following paragraphs after [alg.move]/4:

    template<class ExecutionPolicy, class InputIterator, class OutputIterator>
      OutputIterator move(ExecutionPolicy&& policy, InputIterator first, InputIterator last,
                          OutputIterator result);
    

    -?- Requires: The ranges [first, last) and [result, result + (last - first)) shall not overlap.

    -?- Effects: Moves elements in the range [first, last) into the range [result, result + (last - first)). For each non-negative integer n < (last - first), performs *(result + n) = std::move(*(first + n)).

    -?- Returns: result + (last - first).

    -?- Complexity: Exactly last - first assignments.

Date: 2017-02-02.00:41:18

[ 2016-05 Issues Telecon ]

Marshall noted that all three versions of copy have subtly different wording, and suggested that they should not.

Date: 2016-03-23.00:00:00

[algorithms.parallel.overloads]/2 says that "Unless otherwise specified, the semantics of ExecutionPolicy algorithm overloads are identical to their overloads without."

There's no "otherwise specified" for the ExecutionPolicy overloads for std::copy and std::move, so the requirement that they "start[] from first and proceed[] to last" in the original algorithm's description would seem to apply, which defeats the whole point of adding a parallel overload.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-06-28 12:50:44adminsetstatus: ready -> wp
2016-05-22 15:38:38adminsetmessages: + msg8136
2016-05-22 15:38:38adminsetstatus: new -> ready
2016-05-06 17:10:28adminsetmessages: + msg8079
2016-03-23 00:00:00admincreate