diff --git a/.clang-tidy b/.clang-tidy index d04beea3e..a4eab6ad8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -8,6 +8,7 @@ readability-container-size-empty, modernize-use-using, modernize-use-equals-default, modernize-use-auto, +modernize-use-emplace, ' HeaderFilterRegex: 'pybind11/.*h' diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index ec7fc4a56..3185d4bd7 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -543,7 +543,7 @@ protected: self_value_and_holder.type->dealloc(self_value_and_holder); call.init_self = PyTuple_GET_ITEM(args_in, 0); - call.args.push_back(reinterpret_cast(&self_value_and_holder)); + call.args.emplace_back(reinterpret_cast(&self_value_and_holder)); call.args_convert.push_back(false); ++args_copied; } diff --git a/tests/pybind11_tests.cpp b/tests/pybind11_tests.cpp index 76e0298e8..24b65df6f 100644 --- a/tests/pybind11_tests.cpp +++ b/tests/pybind11_tests.cpp @@ -32,11 +32,11 @@ std::list> &initializers() { } test_initializer::test_initializer(Initializer init) { - initializers().push_back(init); + initializers().emplace_back(init); } test_initializer::test_initializer(const char *submodule_name, Initializer init) { - initializers().push_back([=](py::module &parent) { + initializers().emplace_back([=](py::module &parent) { auto m = parent.def_submodule(submodule_name); init(m); });