[C++-sig] Re: return value policy for returning same python object...

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Jun 10 22:59:38 CEST 2003


--- Milind Patil <milind_patil at hotmail.com> wrote:
> What if this function is overloaded eg. also have
> 
> do_iadd (back_reference<Y&> self, char* other)
> {
>         self.get() += Y_FromString(other);
>        return self.source();
> }
> 
> Having a single
> 
> .def("__iadd__", &do_iadd)
> 
> invokes compilation error...

Sometimes casts are difficult to avoid, but if you have Boost.Python specific
functions anyway (e.g. back_reference<> in the signature) you can easily avoid
the ugly and error-prone casts by naming the functions differently, e.g.

do_iadd_1(...)
do_iadd_2(...)

 .def("__iadd__", &do_iadd_1)
 .def("__iadd__", &do_iadd_2)

Ralf


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com




More information about the Cplusplus-sig mailing list