Boost logo

Boost :

From: SRobb_at_[hidden]
Date: 2004-07-08 12:04:15


> > I wrote that very thing a year or so ago for the purpose of
> testing if a
> > base pointer type can be statically downcast to a derived type.
>
> My problem exactly !

  I should warn you that this isn't quite enough information to test for
static downcastability in all cases. Take the following example:

struct b1 {};
struct b2 : b1 {};
struct b3 : virtual b2 {};

  Here, b1 is not a virtual base of b3, but a downcast from b1* to b3* is
still impossible. I don't believe there is any way to test for this case
without compiler assistance.

  Testing for a virtual base happened to be good enough for us though, so we
went with it; it may well be enough for your needs too.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk