Skip to content

c++17 std copy并行拷贝vector问题,resize如何不要零初始化 #2

@qq1174159858

Description

@qq1174159858

dstVec每次都要resize,相当于全拷贝了一次了,在做copy就没意义了,reverse也不能直接设置size,有没有办法去掉这个赋值,比如直接new char[]这种方式,不会默认填充值
std::vector srcVec(300 * 1024 * 1024, 'a');

std::vector<char> dstVec;
dstVec.resize(srcVec.size());

std::copy(std::execution::par, srcVec.begin(), srcVec.end(), dstVec.begin());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions