This updates the `py::init` constructors to only use brace
initialization for aggregate initiailization if there is no constructor
with the given arguments.
This, in particular, fixes the regression in #1247 where the presence of
a `std::initializer_list<T>` constructor started being invoked for
constructor invocations in 2.2 even when there was a specific
constructor of the desired type.
The added test case demonstrates: without this change, it fails to
compile because the `.def(py::init<std::vector<int>>())` constructor
tries to invoke the `T(std::initializer_list<std::vector<int>>)`
constructor rather than the `T(std::vector<int>)` constructor.
By only using `new T{...}`-style construction when a `T(...)`
constructor doesn't exist, we should bypass this by while still allowing
`py::init<...>` to be used for aggregate type initialization (since such
types, by definition, don't have a user-declared constructor).
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| test_cmake_build | Loading commit data... | |
| test_embed | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| conftest.py | Loading commit data... | |
| constructor_stats.h | Loading commit data... | |
| local_bindings.h | Loading commit data... | |
| object.h | Loading commit data... | |
| pybind11_cross_module_tests.cpp | Loading commit data... | |
| pybind11_tests.cpp | Loading commit data... | |
| pybind11_tests.h | Loading commit data... | |
| pytest.ini | Loading commit data... | |
| test_buffers.cpp | Loading commit data... | |
| test_buffers.py | Loading commit data... | |
| test_builtin_casters.cpp | Loading commit data... | |
| test_builtin_casters.py | Loading commit data... | |
| test_call_policies.cpp | Loading commit data... | |
| test_call_policies.py | Loading commit data... | |
| test_callbacks.cpp | Loading commit data... | |
| test_callbacks.py | Loading commit data... | |
| test_chrono.cpp | Loading commit data... | |
| test_chrono.py | Loading commit data... | |
| test_class.cpp | Loading commit data... | |
| test_class.py | Loading commit data... | |
| test_constants_and_functions.cpp | Loading commit data... | |
| test_constants_and_functions.py | Loading commit data... | |
| test_copy_move.cpp | Loading commit data... | |
| test_copy_move.py | Loading commit data... | |
| test_docstring_options.cpp | Loading commit data... | |
| test_docstring_options.py | Loading commit data... | |
| test_eigen.cpp | Loading commit data... | |
| test_eigen.py | Loading commit data... | |
| test_enum.cpp | Loading commit data... | |
| test_enum.py | Loading commit data... | |
| test_eval.cpp | Loading commit data... | |
| test_eval.py | Loading commit data... | |
| test_eval_call.py | Loading commit data... | |
| test_exceptions.cpp | Loading commit data... | |
| test_exceptions.py | Loading commit data... | |
| test_factory_constructors.cpp | Loading commit data... | |
| test_factory_constructors.py | Loading commit data... | |
| test_iostream.cpp | Loading commit data... | |
| test_iostream.py | Loading commit data... | |
| test_kwargs_and_defaults.cpp | Loading commit data... | |
| test_kwargs_and_defaults.py | Loading commit data... | |
| test_local_bindings.cpp | Loading commit data... | |
| test_local_bindings.py | Loading commit data... | |
| test_methods_and_attributes.cpp | Loading commit data... | |
| test_methods_and_attributes.py | Loading commit data... | |
| test_modules.cpp | Loading commit data... | |
| test_modules.py | Loading commit data... | |
| test_multiple_inheritance.cpp | Loading commit data... | |
| test_multiple_inheritance.py | Loading commit data... | |
| test_numpy_array.cpp | Loading commit data... | |
| test_numpy_array.py | Loading commit data... | |
| test_numpy_dtypes.cpp | Loading commit data... | |
| test_numpy_dtypes.py | Loading commit data... | |
| test_numpy_vectorize.cpp | Loading commit data... | |
| test_numpy_vectorize.py | Loading commit data... | |
| test_opaque_types.cpp | Loading commit data... | |
| test_opaque_types.py | Loading commit data... | |
| test_operator_overloading.cpp | Loading commit data... | |
| test_operator_overloading.py | Loading commit data... | |
| test_pickling.cpp | Loading commit data... | |
| test_pickling.py | Loading commit data... | |
| test_pytypes.cpp | Loading commit data... | |
| test_pytypes.py | Loading commit data... | |
| test_sequences_and_iterators.cpp | Loading commit data... | |
| test_sequences_and_iterators.py | Loading commit data... | |
| test_smart_ptr.cpp | Loading commit data... | |
| test_smart_ptr.py | Loading commit data... | |
| test_stl.cpp | Loading commit data... | |
| test_stl.py | Loading commit data... | |
| test_stl_binders.cpp | Loading commit data... | |
| test_stl_binders.py | Loading commit data... | |
| test_virtual_functions.cpp | Loading commit data... | |
| test_virtual_functions.py | Loading commit data... |