Hi Boosters

I'm trying to export some base class' methods with the derived class directly. See the following code:

// -----------------------------------------------------
#include <boost/python.hpp>

struct my_base_class
{
int const & get_base_i() const
{
return i_;
}
int i_;
};

struct my_class
: my_base_class
{
int const & get_i() const
{
return i_;
}

int i_;
};

using namespace boost::python;

BOOST_PYTHON_MODULE(_test)
{
class_<my_class>("MyClass")
.add_property("i", make_function(&my_class::get_i, return_value_policy<copy_const_reference>()))
.add_property("basei", make_function(&my_class::get_base_i, return_value_policy<copy_const_reference>()))
;
}

// -----------------------------------------------------

Now python throws the following at me:

h[ 1] >>> from _test import *
h[ 1] >>> MyClass().basei
Traceback (most recent call last):
File "<stdin>", line 1, in ?
Boost.Python.ArgumentError: Python argument types in
None.None(MyClass)
did not match C++ signature:
None(my_base_class {lvalue})

So, my question is: Am I not supposed to do this at all? The same seems to work flawlessly when returning by value instead of by reference....

Thanks for your input

Bernhard
___________________________________________________________________

Disclaimer:


Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimmt.

Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird, bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden und anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopien zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verboten.


This message is intended only for the named recipient and may contain confidential or privileged information.

If you have received it in error, please advise the sender by return e-mail and delete this message and any attachments. Any unauthorised use or dissemination of this information is strictly prohibited.