[C++-sig] make_constructor, with_custodian_and_ward problems (again)
Neal Becker
ndbecker2 at gmail.com
Thu Sep 13 16:55:39 CEST 2007
What's the correct way to do this? Neither of the below .defs will compile:
multi_array_ref<int,1>* make_array_int_1 (object & o) {
void* buffer;
bp::ssize_t size;
int ret = PyObject_AsWriteBuffer (o.ptr(), &buffer, &size);
return new multi_array_ref<int,1> (static_cast<int*>(buffer),
extents[size/sizeof(int)]);
}
BOOST_PYTHON_MODULE(multi_array) {
def ("make_buffer", &make_buffer);
class_<multi_array_ref<int,1> > ("multi_array_int_1", no_init)
.def ("__init__", make_constructor (&make_array_int_1), with_custodian_and_ward_postcall<0,1>())
.def ("__init__", make_constructor (&make_array_int_1, with_custodian_and_ward_postcall<0,1>()))
;
}
This same question was raised before, but I don't see a correct answer:
http://mail.python.org/pipermail/c++-sig/2007-June/012470.html
More information about the Cplusplus-sig
mailing list