[C++-sig] Re: New-style polymorphism

David Abrahams dave at boost-consulting.com
Tue Jul 27 14:58:19 CEST 2004


Daniel Wallin <dalwan01 at student.umu.se> writes:

> David Abrahams wrote:
>> I hope to get this documented before the release, but in case I
>> don't, the old method still works; I'd like people to get some
>> experience with this new feature though, so I can see if it's working
>> out as it should.
>
> Here's a problem: Trying to call a base class member function statically
> from python will call the virtual function, resulting in infinite
> recursion.

#*&!!!@@

How could I miss that one?  And how did it ever work, even with the
existing mechanism?

I'll look into this, but I'm not optimistic it can be fixed :(.

> -- 
> Daniel Wallin
> from failed import *
>
> class B(A):
>     def f(self):
>         A.f(self)
>
> B().f()
>
>
> #include <boost/python/module.hpp>
> #include <boost/python/wrapper.hpp>
> #include <boost/python/class.hpp>
>
> using namespace boost::python;
>
> struct A
> {
>     virtual ~A() {}
>     virtual void f() {}
> };
>
> struct AWrap : A, wrapper<A> 
> {
>     void f()
>     {
>         if (override f = get_override("f"))
>         {
>             f();
>         }
>         else
>         {
>             A::f();
>         }
>     }
> };
>
> BOOST_PYTHON_MODULE(failed)
> {
>     class_<AWrap, boost::noncopyable>("A")
>         .def("f", &A::f);
> }
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig

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




More information about the Cplusplus-sig mailing list