Boost logo

Boost Users :

From: dkottowk (dkottowk_at_[hidden])
Date: 2002-09-04 09:55:29


hi,
please consider the following example

class A {
public:
 A() {}
 A(const A& a) {}
};

class A2 : public A {
public:
 A2() : A() {}
 A2(const A2& a2) : A(a2) {}
};

class B {
public:
 const A& getA(); //returns refs to A or A2
};

now, when exposing this in boost, i would always get A's when
calling B::getA() from python, which i understand, since AFAIK
the copy Ctors are used to instantiate the python object.

to overcome this i wrote:

PyObject *to_python(const A &a) {
  if (dynamic_cast<A2*>(&a)) {
     return to_python::((const A2 &)a);//done by class_builder<A2>
  } else {
     //HOW DO I CALL THE IMPL DONE BY class_builder<A> ?
     return 0;
  }
}

which works fine, except that i dont know how to resort to the
automatic implementation for
PyObject *to_python(const A& a)
provided by the class builder for A.

any help is greatly appreciated.
greetings, daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net