[C++-sig] Re: make_constructor & keyword arguments?
David Abrahams
dave at boost-consulting.com
Mon Aug 9 16:28:46 CEST 2004
"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:
> Is it possible to add keyword argument support to a constructor injected with
> boost::python::make_constructor? I tried this
>
> .def("__init__",
> boost::python::make_constructor(from_iselection_unsigned),
> (arg_("size"), arg_("iselection")))
>
> but it doesn't compile ("incomplete type").
Full error message please?
> I also tried using operator() and
> operator[] of the make_constructor instance; it compiles but doesn't work at
> runtime.
Not surprising. make_constructor just returns a callable
python::object, so operator() and operator[] just do the ordinary
things you might expect to that object.
> What is the correct syntax?
I think you need a "self" argument, though I might be wrong.
.def("__init__",
boost::python::make_constructor(
from_iselection_unsigned
, (arg_("self"), arg_("size"), arg_("iselection"))
))
The reference docs for make_function/make_constructor need to be
fixed, as I posted last week.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list