From 4d7864083064975239befb80e3cb2479b4610fb5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 10 Sep 2020 23:26:50 -0400 Subject: [PATCH] style: clang-tidy: modernize-use-emplace --- .clang-tidy | 1 + include/pybind11/pybind11.h | 2 +- tests/pybind11_tests.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d04beea3..a4eab6ad 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 ec7fc4a5..3185d4bd 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 76e0298e..24b65df6 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); });