[C++-sig] Py++ and 'using' declarations
Roman Yakovenko
roman.yakovenko at gmail.com
Tue Jun 19 11:20:54 CEST 2007
On 6/19/07, Pertti Kellomäki <pk at cs.tut.fi> wrote:
> Is there a way in Py++ to deal with overloaded member functions
> introduced by 'using' declarations?
>
> For example, for the following declarations, Py++ creates
> the code below.
>
> -----------------------------------------------------
> class B {
> public:
> void f();
> };
>
> class D : public B {
> public:
> void f(int i);
> using B::f;
> };
> -----------------------------------------------------
> // This file has been generated by Py++.
> #include "boost/python.hpp"
> #include "killme.hh"
> namespace bp = boost::python;
>
> BOOST_PYTHON_MODULE(killme){
> bp::class_< B >( "B" )
> .def("f", &::B::f );
> bp::class_< D, bp::bases< B > >( "D" )
> .def("f", &::D::f, ( bp::arg("i") ) );
> }
> -----------------------------------------------------
>
> Compiling this with g++ results in an "unresolved overloaded
> function type" error, because g++ cannot choose between
> D::f() and D::f(int).
You don't need "using":
mb = module_builder_t( ... )
D = mb.class_( 'D' )
D.mem_fun( 'f' ).create_with_signature = True
#or:
mb.calldefs().create_with_signature = True #for all functions
You can read more in documentation about the property:
http://language-binding.net/pyplusplus/documentation/apidocs/pyplusplus.decl_wrappers.calldef_wrapper.calldef_t-class.html#create_with_signature
P.S. I will tweak Py++ to be aware to such use case, and it will guess
right the default value of the property.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list