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

David Abrahams dave at boost-consulting.com
Mon Aug 9 21:26:20 CEST 2004

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

> This compiles without a problem and the following Python code still works as
> expected (i.e. prints the value 105):
> from injected_ext import *
> print X(3,5,7).value()
> However, this line results in an error:
> print X(3,5,c=7).value()
> Traceback (most recent call last):
>   File "/net/cci/rwgk/zi", line 3, in ?
>     print X(3,5,c=7).value()
> Boost.Python.ArgumentError: Python argument types in
>     X.__init__(X, int, int)
> did not match C++ signature:
>     __init__(boost::python::api::object, int, int, int)
>     __init__(boost::python::api::object, int, int)
>     __init__(boost::python::api::object)
>     __init__(_object*, int)
> I'd expect to see the the keywords in the traceback, e.g.:
>     __init__(boost::python::api::object, int a, int b, int c)
> Could it be that my list of arg's is not actually used in make_constructor.hpp?

I don't think that's the problem.  Try changing (in make_constructor.hpp):

      enum { arity = mpl::size<Sig>::value - 1 };

      enum { arity = mpl::size<Sig>::value };
Then add back the "self" keyword and let me know if it works.  If it
all works, please check in your modifications to the test and the

Thanks (sorry)

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list