mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
5fffe200e3
The current pybind11::class_<Type, Holder, Trampoline> fixed template ordering results in a requirement to repeat the Holder with its default value (std::unique_ptr<Type>) argument, which is a little bit annoying: it needs to be specified not because we want to override the default, but rather because we need to specify the third argument. This commit removes this limitation by making the class_ template take the type name plus a parameter pack of options. It then extracts the first valid holder type and the first subclass type for holder_type and trampoline type_alias, respectively. (If unfound, both fall back to their current defaults, `std::unique_ptr<type>` and `type`, respectively). If any unmatched template arguments are provided, a static assertion fails. What this means is that you can specify or omit the arguments in any order: py::class_<A, PyA> c1(m, "A"); py::class_<B, PyB, std::shared_ptr<B>> c2(m, "B"); py::class_<C, std::shared_ptr<C>, PyB> c3(m, "C"); It also allows future class attributes (such as base types in the next commit) to be passed as class template types rather than needing to use a py::base<> wrapper. |
||
---|---|---|
.. | ||
CMakeLists.txt | ||
conftest.py | ||
constructor_stats.h | ||
object.h | ||
pybind11_tests.cpp | ||
pybind11_tests.h | ||
test_buffers.cpp | ||
test_buffers.py | ||
test_callbacks.cpp | ||
test_callbacks.py | ||
test_class_args.cpp | ||
test_class_args.py | ||
test_constants_and_functions.cpp | ||
test_constants_and_functions.py | ||
test_eigen.cpp | ||
test_eigen.py | ||
test_enum.cpp | ||
test_enum.py | ||
test_eval_call.py | ||
test_eval.cpp | ||
test_eval.py | ||
test_exceptions.cpp | ||
test_exceptions.py | ||
test_inheritance.cpp | ||
test_inheritance.py | ||
test_issues.cpp | ||
test_issues.py | ||
test_keep_alive.cpp | ||
test_keep_alive.py | ||
test_kwargs_and_defaults.cpp | ||
test_kwargs_and_defaults.py | ||
test_methods_and_attributes.cpp | ||
test_methods_and_attributes.py | ||
test_modules.cpp | ||
test_modules.py | ||
test_numpy_dtypes.cpp | ||
test_numpy_dtypes.py | ||
test_numpy_vectorize.cpp | ||
test_numpy_vectorize.py | ||
test_opaque_types.cpp | ||
test_opaque_types.py | ||
test_operator_overloading.cpp | ||
test_operator_overloading.py | ||
test_pickling.cpp | ||
test_pickling.py | ||
test_python_types.cpp | ||
test_python_types.py | ||
test_sequences_and_iterators.cpp | ||
test_sequences_and_iterators.py | ||
test_smart_ptr.cpp | ||
test_smart_ptr.py | ||
test_stl_binders.cpp | ||
test_stl_binders.py | ||
test_virtual_functions.cpp | ||
test_virtual_functions.py |