[C++-sig] Re: How to expose virtual function with defaultarguments in boost.python ?

David Abrahams dave at boost-consulting.com
Wed Dec 8 13:19:35 CET 2004


Baptiste Lepilleur wrote:

> From: "David Abrahams" <dave at boost-consulting.com>

>> Baptiste Lepilleur wrote:


>> > There should definitely be
>> > a note about this warning in either the tutorial or the reference
>> > documentation.
>>
>> Where, precisely, do you think the note could go that would be helpful?
>>  The warning shows up in all kinds of places, and not only with
>> Boost.Python.  If it will be helpful, I'm all for adding a note, but in
>> general I'm disinclined to devote much attention to suppressing buggy
>> warnings.  I don't want the documentation to become a pile of notes
>> about quirky compiler bugs.
> 
> I never run into that bugged warning before. Given the compilation error I
> run into above, I would simply suggest that the work-around should be used
> on vc6/7/7.1.
> 
>> > It worries me that such a serious warning is bugged. It's one of a few
> that
>> > I really look out for. By the way, how do you manage to return a
> reference
>> > on something that is temporary (return value of the python function
> call) ?
>> > I'm curious...

Hint: http://home.in.tum.de/~jain/software/oe-quotefix/

>> I am not returning a reference to a temporary; that's why I say the
>> warning is a compiler bug.  The warning is just incorrect.
> 
> I understood that you were not returning a reference to a temporary. My
> question is how you managed to achieve that, since a return value is by
> essence temporary.

A conversion operator is invoked that converts the temporary into the
reference type.  If the temporary has only a single reference to its
underlying Python object, an exception occurs at runtime.  Otherwise we
can be assured that the referent will persist past the return statement.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list