Hacker News new | ask | show | jobs
by abbeyj 694 days ago
> The student dutifully changed the line, and both tools reported their satisfaction with the replacement

clang-tidy's `modernize-use-emplace` check warns for both the original version that uses `push_back` (as quoted in the article) and for the modified version that uses `emplace_back`:

    warning: unnecessary temporary object created while calling emplace_back [modernize-use-emplace]
       13 |     widgets.emplace_back(Widget(foo, bar, baz));
          |                          ^~~~~~~             ~
https://godbolt.org/z/sE7jWacTf

It appears that this check was improved to add this warning at some point between clang v14 and now. At least things have improved since the article was written.