From: "Johan Nilsson" <[EMAIL PROTECTED]>
>
> "Peter Dimov" <[EMAIL PROTECTED]> wrote in message
> 00bb01c2a046$671b1c20$1d00a8c0@pdimov2">news:00bb01c2a046$671b1c20$1d00a8c0@pdimov2...
> > From: "Johan Nilsson" <[EMAIL PROTECTED]>
> > [...]
> > > template<typename T>
> > > T* dynamic_void_cast(void* pv)
> > > {
> > >   struct rtti_obj__
> > >   {
> > >     virtual ~rtti_obj__() = 0;
> > >   };
> > >
> > >   rtti_obj__* pro = static_cast<rtti_obj__*>(pv);
> > >
> > >   try
> > >   {
> > >     return dynamic_cast<T*>(pro);
> > >   }
> >
> > This is not required to work. T's vtable pointer is not guaranteed to be
> at
> > offset 0.

Actually I meant *pv's vtable pointer here.

> But I thought that it _might_ be required to be at the same offset for T
as
> for rtti_obj. For that part, IIRC, a vtable isn't required at all, or?

Try it (on several compilers, as some do put the vptr at offset 0.)

struct X { int n; };
struct Y: public X { virtual ~Y() {} };

Y+0: X::n
Y+4: vptr

rtti_obj__+0: vptr

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to