[C++-sig] errors while setting arguments description for the method

Jim Bosch talljimbo at gmail.com
Wed Mar 17 23:30:19 CET 2010


On Wed, 2010-03-17 at 22:21 +0000, Gennadiy Rozental wrote:
> I've got specification like this:
> 
>     class_<Foo,FooSP>( "Foo", "Foo descr" )
>      .def( "__init__", bp::make_constructor( &make_foo ), 
>            bp::args( "self", "str" ), 
>            "Constructor based on string representation.\n" )
> ...
> 
> I am getting compilation error below from VC9.0. Error disappears if I avoid
> bp::args( "self", "str" ) part.
> 
> Please advise,
> 

You have to pass the keywords to make_constructor:

.def("__init__",
     bp::make_constructor(&make_foo, 
         bp::default_call_policies(), bp::args("self","str"))
    )

I'm not actually sure whether to put the docstring in the call to
make_constructor (I'll let you experiment), but you do have to supply
the call policies argument manually if you want to supply keywords -
make_constructor just doesn't have the overloads that make_function
does.


Jim Bosch




More information about the Cplusplus-sig mailing list