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

Bilokon, Paul paul.bilokon at lehman.com
Fri Aug 22 14:21:04 CEST 2008


Thanks Dave,

Having different names for the static / non-static methods on the Python
side is not too big a problem.

Many thanks,
Paul

-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of David Abrahams
Sent: Friday, August 22, 2008 4:29 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Static and non-static functions with the same
name


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
_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.




More information about the Cplusplus-sig mailing list