[C++-sig] Re: make_constructor & keyword arguments?

David Abrahams dave at boost-consulting.com
Mon Aug 9 18:13:46 CEST 2004


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> Using this code exactly (copy-and-paste) I am getting the following error
> messages:
>
> Linux RH8, gcc 3.4.0:
> http://cci.lbl.gov/~rwgk/tmp/make_constructor_keyword_problem_gcc340
>
> Tru64 5, cxx 6.5 (EDG 245):
> http://cci.lbl.gov/~rwgk/tmp/make_constructor_keyword_problem_cxx65
>
> I also tried without the arg_("self") but the errors are pretty much the same.

Oh, whoops, you need call policies if you want to supply keywords:

        .def("__init__",
             boost::python::make_constructor(
                 from_iselection_unsigned
                 , boost::python::default_call_policies()
                 , (arg_("self"), arg_("size"), arg_("iselection"))
             ))

It should be fairly obvious from looking at make_constructor.hpp (I
know that's a lame excuse for inadequate documentation).

> BTW: typedef boost::python::arg arg_; // gcc 2.96 workaround

You can add that typedef to args.hpp if you like.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list