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

David Abrahams dave at boost-consulting.com
Tue Jun 10 04:20:03 CEST 2003


"Milind Patil" <milind_patil at hotmail.com> writes:

> "David Abrahams" <dave at boost-consulting.com> wrote in message
> news:uy90cnrzz.fsf at boost-consulting.com...
>> "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:
>>
>> > --- David Abrahams <dave at boost-consulting.com> wrote:
>> >> David Abrahams <dave at boost-consulting.com> writes:
>> >> >     const object
>> >> >     do_iadd (back_reference<Y&> self, int other)
>> >> >     {
>> >> >        self.get() += Y_FromInt(other);
>> >> >        return self.source();
>> >> >     }
>> >
>
> Thank you both, for the solution.
>
> object
> do_iadd (back_reference<Y&> self, int other)
> {
>      self.get() += Y_FromInt(other);
>      return self.source();
> }
>
> and
>
> .def("__iadd__", (object (*)(back_reference<Y&>, int) )&do_iadd)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Why this dangerous cast?  It's completely unneccessary, and I
cautioned you against it.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list