[C++-sig] Re: def() vs. add_property()

David Abrahams dave at boost-consulting.com
Wed Jul 16 22:55:55 CEST 2003

Stefan Seefeld <seefeld at sympatico.ca> writes:

> David Abrahams wrote:
>> Stefan Seefeld <stefan.seefeld at orthosoft.ca> writes:
>>>hi there,
>>>I'v got a class that holds a reference to an external
>>>object, which is accessible through a simple method:
>>>class Origin {};
>>>class Event
>>>   Event(const Origin *o) : my_origin(o) {}
>>>   const Origin *GetOrigin() { return my_origin;}
>>>   const Origin *my_origin;
>>>I can expose the 'Event' and 'Origin' classes, as well
>>>as &Event::GetOrigin, to python.
>>>However, I'd rather like to make the origin accessible
>>>as a (read-only) property. The problem is that the
>>>'add_property' method doesn't take a return value policy,
>>>so I have no way of telling python how to wrap the pointer.
>>>What is the suggested way to do that ?
>> See make_getter/make_setter.  You can pass their results to
>> add_property.
> make_getter seems to expect a pointer-to-member, while I
> want a pointer-to-member-function. Am I missing something ?


Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list