【发布时间】:2020-07-05 00:03:32
【问题描述】:
这是来自cppreference.com 对std::copy(https://en.cppreference.com/w/cpp/algorithm/copy) 的引用。
Complexity
1-2) Exactly (last - first) assignments
3-4) Exactly (last - first) applications of the predicate, between 0 and (last - first) assignments (assignment for every element for which predicate is equal to true, dependent on predicate and input data)
For the overloads with an ExecutionPolicy, there may be a performance cost if ForwardIt1's value type is not MoveConstructible.
很明显,std::copy 的并行版本应该做额外的工作来组织并行性,它的复杂性可能会增加。我想了解它可能会高多少以及何时发生。
如果值类型不是MoveConstructible,也意味着它不是CopyConstuctible,对吧?那么我们如何复制那种对象呢?谁能提供一个我们因此而受到性能损失的例子。
【问题讨论】:
标签: c++ c++17 c++-standard-library