Skip to content

[clang-tidy][C++20] False negative modernize-use-emplace when passing init list #104434

Open
@chrchr-github

Description

@chrchr-github
#include <string>
#include <vector>

struct S {
    std::string s;
};

void f(std::string a) {
    std::vector<S> v;
    v.push_back({std::move(a)}); // no warning
}

https://godbolt.org/z/4jrj1M6hY
With C++20, v.emplace_back(std::move(a)); should be used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions