[C++-sig] Static and non-static functions with the same name

Ravi lists_ravi at lavabit.com
Tue Aug 19 16:52:35 CEST 2008


On Tuesday 19 August 2008 09:10:23 Bilokon, Paul wrote:
> using namespace boost::python;
>
> BOOST_PYTHON_MODULE(overloading)
> {
>     class_<Foo>("Foo")
>         .def("garply", (string (*)(string)) &Foo::garply)
>         .def("garply", (string (Foo::*)(int, int)) &Foo::garply)
>         .staticmethod("garply")
>             // ??? Which garply is that ???
>     ;
> }

Try an extra level of indirection:

using namespace boost::python;

string foo_pygarply( string z ) { return Foo::garply(z); }

BOOST_PYTHON_MODULE(overloading)
{
    class_<Foo>("Foo")
        .def("garply", (string (*)(string)) &Foo::garply)
        .def("garply", (string (Foo::*)(int, int)) &Foo::garply)
        .staticmethod("foo_pygarply")
    ;
}

Regards,
Ravi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080819/c85f5e1f/attachment.htm>


More information about the Cplusplus-sig mailing list