Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several cases with unnecessary temporary objects not detected by modernize-use-emplace #79213

Open
firewave opened this issue Jan 23, 2024 · 1 comment
Labels

Comments

@firewave
Copy link

#include <map>
#include <utility>

void f()
{
    std::map<int, int> m;
    m.insert(std::make_pair(0, 0));
    m.insert(std::pair<int, int>(0, 0));
    m.emplace(std::pair<int, int>(0, 0));

    m.emplace(std::make_pair(0, 0));
}
<source>:11:15: warning: unnecessary temporary object created while calling emplace [modernize-use-emplace]
   11 |     m.emplace(std::make_pair(0, 0));
      |               ^~~~~~~~~~~~~~~    ~

https://godbolt.org/z/8MhYPv9qP

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 23, 2024

@llvm/issue-subscribers-clang-tidy

Author: Oliver Stöneberg (firewave)

```cpp #include <map> #include <utility>

void f()
{
std::map<int, int> m;
m.insert(std::make_pair(0, 0));
m.insert(std::pair<int, int>(0, 0));
m.emplace(std::pair<int, int>(0, 0));

m.emplace(std::make_pair(0, 0));

}


<source>:11:15: warning: unnecessary temporary object created while calling emplace [modernize-use-emplace]
11 | m.emplace(std::make_pair(0, 0));
| ^~~~~~~~~~~~~~~ ~


https://godbolt.org/z/8MhYPv9qP
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants