From: Sam Holden (sholden_at_[hidden])
Date: 2001-04-25 18:39:10
"David Abrahams" writes:
>----- Original Message -----
>From: "Sam Holden" <sholden_at_[hidden]>
>Sent: Tuesday, April 24, 2001 1:42 AM
>Subject: [boost] Help with boost::python...
>> Basically an abstract interface and an implementation (more than one in
>> reality). In reality the abstract interface has some implementation but
>> also contains pure virtual member functions which return references to
>> classes with pure virtual member functions.
>> So does anyone have any experience in getting something similar to work,
>> and could point me in the right direction?
>With the current version of boost::python, you'd need to hold the
>Derived_Result with a boost::shared_ptr (or equivalent) instead of embedding
>it by value, or resort to "dangerous hacks" as described in
Using a wrapper class that held the reference and thus did the virtual
lookup stuff in C++ was my next step, I was just hoping to avoid it. I got
side-tracked by the Overridable Virtual Functions section of the docs and
solved the wrong problem...
The 'dangerous hacks' I missed due to my brain not linking pointers and
references in that context... I think I'll try and avoid that, writing a
wrapper class will be fine (and will give me all the fun of dangling
references//pointers anyway - though that can and will be fixed in this
particular app easily enough).
>Every few months somebody asks this question. I posted a proposed resolution
>http://groups.yahoo.com/group/boost/message/10144, which I would implement
>if I got enough positive feedback. Unfortunately, the thread starting with
>http://groups.yahoo.com/group/boost/message/10479 was the only result, and
>was inconclusive. If my proposal would fill your needs, let me know it. One
>more voice in favor of the original proposal would help tip the scales.
I have to profess ignorance and admit that I don't have enough experience
with python or boost::python (or C++ some would say) to be able to give a
That said, returning references to internal classes doesn't seem all that
uncommon in C++. So being able to support in a simple fashion would probably
be useful - as for the proposed solution I must admit I don't know enough
about how it all works to know if the tradeoffs are worthwhile...
Sorry for being no help at all.
Thanks for being a great help to me.
This doesn't seem fair somehow...
>> Also does boost::python work OK for embedding python as opposed to
>> python? Can I statically link in the extensions for example?
>Yes, but I don't think we have an example of in the code anywhere. However,
>others have made it work.
I figured it would, since boost::python shouldn't care how the system loads
the machine code. Thanks.
-- Sam I would like to tell you that Perl is simple in its complexity. But some people won't understand that. So pretend I didn't say that, unless you do. --Larry Wall
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk