来自n4385
:
§25.6.4 转换:
template<class InputIterator, class OutputIterator, class UnaryOperation>
constexpr OutputIterator
transform(InputIterator first1, InputIterator last1, OutputIterator result, UnaryOperation op);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class UnaryOperation>
ForwardIterator2
transform(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 result, UnaryOperation op);
template<class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
constexpr OutputIterator
transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation binary_op);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class ForwardIterator, class BinaryOperation>
ForwardIterator
transform(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator result, BinaryOperation binary_op);
§23.5.2.1.2 back_inserter
template<class Container>
constexpr back_insert_iterator<Container> back_inserter(Container& x);
返回:back_insert_iterator(x)。
§23.5.2.1 类模板back_insert_iterator
using iterator_category = output_iterator_tag;
因此std::back_inserter
不能与的并行版本一起使用std::transform
。支持输出迭代器的版本通过输入迭代器从其源读取。由于输入迭代器只能进行预递增和后递增(第23.3.5.2节,输入迭代器),并且只能执行顺序(即非并行)执行,因此必须在它们与输出迭代器之间保留顺序。
transform
版本决定是否使用并行处理。该transform
大型向量失败。