Skip to content

[move] move in range for #82

@qqiangwu

Description

@qqiangwu
void foo(std::vector<std::unique_ptr<int>>& cont, std::unique_ptr<int>& p)
{
    for (auto& x : cont) {
        p = std::move(x);
    }

    for (auto& x: cont) {
        use(x);
    }
}

void bar(std::vector<std::unique_ptr<int>>& cont, std::unique_ptr<int>& p)
{
    for (size_t i = 0; i < cont.size(); ++i) {
        p = std::move(cont[i]);
    }

    for (auto& x: cont) {
        use(x);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    badcaseThe defect of the model

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions