Update enum_ and bind_vector to new-style init and pickle
Fixes #1046.
diff --git a/tests/test_buffers.cpp b/tests/test_buffers.cpp
index c7f081d..5be7177 100644
--- a/tests/test_buffers.cpp
+++ b/tests/test_buffers.cpp
@@ -78,13 +78,15 @@
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
.def(py::init<ssize_t, ssize_t>())
/// Construct from a buffer
- .def("__init__", [](Matrix &v, py::buffer b) {
+ .def(py::init([](py::buffer b) {
py::buffer_info info = b.request();
if (info.format != py::format_descriptor<float>::format() || info.ndim != 2)
throw std::runtime_error("Incompatible buffer format!");
- new (&v) Matrix(info.shape[0], info.shape[1]);
- memcpy(v.data(), info.ptr, sizeof(float) * (size_t) (v.rows() * v.cols()));
- })
+
+ auto v = new Matrix(info.shape[0], info.shape[1]);
+ memcpy(v->data(), info.ptr, sizeof(float) * (size_t) (v->rows() * v->cols()));
+ return v;
+ }))
.def("rows", &Matrix::rows)
.def("cols", &Matrix::cols)