Description
[Edit: Just tested the old approach and it also raises cast exceptions on 2.5, so perhaps the issue does not directly relate to the deprecation. However the code was working as expected previouslty, so my question of how to achieve the desired result in 2.5 still stands.]
I've only just updated from pre-2.2 so perhaps this has been brought up, but my searching hasn't uncovered anything. I had a class exposed based on the Matrix example in the docs, under Numpy/Buffer Protocol. (NOTE: This docs example still uses the now deprecated "__init__" form of constructor)
I updated my code to the new form as instructed by the runtime warning, going from
.def("__init__", [] (MyType& v, py::array_t< Coord > ar) { ... })
to
.def(py::init([] (py::array_t< Coord > ar) { ... }))
This gets rid of the warning, however py_obj.cast< MyType >()
(where py_obj is some type with a buffer protocol), which was converting fine before, is now throwing an exception.
If this is intentional, what is the recommended approach now in order to get the behaviour of constructing a bound C++ type from an arbitrary buffer protocol-supporting Python object?