style: clang-tidy: modernize-use-emplace

This commit is contained in:
Henry Schreiner 2020-09-10 23:26:50 -04:00 committed by Henry Schreiner
parent ce88e940ce
commit 4d78640830
3 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ readability-container-size-empty,
modernize-use-using, modernize-use-using,
modernize-use-equals-default, modernize-use-equals-default,
modernize-use-auto, modernize-use-auto,
modernize-use-emplace,
' '
HeaderFilterRegex: 'pybind11/.*h' HeaderFilterRegex: 'pybind11/.*h'

View File

@ -543,7 +543,7 @@ protected:
self_value_and_holder.type->dealloc(self_value_and_holder); self_value_and_holder.type->dealloc(self_value_and_holder);
call.init_self = PyTuple_GET_ITEM(args_in, 0); call.init_self = PyTuple_GET_ITEM(args_in, 0);
call.args.push_back(reinterpret_cast<PyObject *>(&self_value_and_holder)); call.args.emplace_back(reinterpret_cast<PyObject *>(&self_value_and_holder));
call.args_convert.push_back(false); call.args_convert.push_back(false);
++args_copied; ++args_copied;
} }

View File

@ -32,11 +32,11 @@ std::list<std::function<void(py::module &)>> &initializers() {
} }
test_initializer::test_initializer(Initializer init) { test_initializer::test_initializer(Initializer init) {
initializers().push_back(init); initializers().emplace_back(init);
} }
test_initializer::test_initializer(const char *submodule_name, Initializer 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); auto m = parent.def_submodule(submodule_name);
init(m); init(m);
}); });