[C++-sig] Static and non-static functions with the same name
David Abrahams
dave at boostpro.com
Fri Aug 22 05:28:37 CEST 2008
on Wed Aug 20 2008, "Bilokon, Paul" <paul.bilokon-AT-lehman.com> wrote:
> Hi Ravi,
>
> If my understanding is correct, this method has the same deficiency as
> simply doing this:
>
> // OK, explicitly specifying the static garply(string):
> .def("staticGarply", (string (*)(string)) &Foo::garply)
> .staticmethod("staticGarply")
> // OK, explicitly specifying the non-static garply(int, int):
> .def("garply", (string (Foo::*)(int, int)) &Foo::garply)
>
> // NB: The syntax: (*) for static, (Foo::*) for non-static
>
> // NB: Since staticmethod does not distinguish between the method
> // signatures, we must give the static and non-static variants
> // distinct names in Python
>
> This works, but the static and non-static variants end up having different
> names on the Python side.
There's not much you can really do about that, since there's no real
overloading in Python; it's just simulated by Boost.Python.
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
More information about the Cplusplus-sig
mailing list