pybind11/docs/advanced/pycpp
Bruce Merry b82c0f0a2d Allow std::complex field with PYBIND11_NUMPY_DTYPE (#831)
This exposed a few underlying issues:

1. is_pod_struct was too strict to allow this. I've relaxed it to
require only trivially copyable and standard layout, rather than POD
(which additionally requires a trivial constructor, which std::complex
violates).

2. format_descriptor<std::complex<T>>::format() returned numpy format
strings instead of PEP3118 format strings, but register_dtype
feeds format codes of its fields to _dtype_from_pep3118. I've changed it
to return PEP3118 format codes. format_descriptor is a public type, so
this may be considered an incompatible change.

3. register_structured_dtype tried to be smart about whether to mark
fields as unaligned (with ^). However, it's examining the C++ alignment,
rather than what numpy (or possibly PEP3118) thinks the alignment should
be. For complex values those are different. I've made it mark all fields
as ^ unconditionally, which should always be safe even if they are
aligned, because we explicitly mark the padding.
2017-05-10 11:36:24 +02:00
..
index.rst Reorganize documentation 2016-10-20 15:21:34 +02:00
numpy.rst Allow std::complex field with PYBIND11_NUMPY_DTYPE (#831) 2017-05-10 11:36:24 +02:00
object.rst Automate generation of reference docs with doxygen and breathe (#598) 2017-01-31 16:54:08 +01:00
utilities.rst Add py::exec() as a shortcut for py::eval<py::eval_statements>() 2017-05-08 20:46:16 +02:00