Boost logo

Boost :

From: quendezus (quendez_at_[hidden])
Date: 2002-01-14 06:10:28


--- In boost_at_y..., Lee Brown <lee_at_a...> wrote:
> On Sunday 13 January 2002 13:59, you wrote:
> > ----- Original Message -----
> > From: "Lee Brown" <lee_at_a...>
> >
> > > > template <class T>
> > > > struct is_polymorphic
> > > > {
> > > > struct d1 : public T
> > > > {
> > > > d1();
> > > > char padding[256];
> > > > };
> > > > struct d2 : public T
> > > > {
> > > > d2();
> > > > virtual ~d2();
> > > > virtual void foo();
> > > > char padding[256];
> > > > };
> > > > BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof
(d1)));
> > > > };
> > >
> > > This reminds me of the guy who got wings and flew too close to
the sun.
> > > I understand that a programmer sometimes has got to do what
he's got to
> > > do, but .... C++ was designed to avoid this sort of hack.
> >
> > I have to disagree.
>

This code afraids me a bit. Is there feedback that it generally
works ? I'd like to hear other opinions.

For now, I use a run time assertion to check if a class is
polymorphic or not (as describe at the end of "A Generic Non-
Intrusive Smart Pointer Implementation", from
http://cplusplus.anthonyw.cjb.net/articles.html). I would prefere a
compile time assertion but only if is reasonably portable.

Sylvain


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