Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-04-09 15:47:17


On Wed, 2008-04-09 at 14:18 -0400, Frank Mori Hess wrote:
> On Wednesday 09 April 2008 14:13 pm, Daniel Frey wrote:
> > static_cast<T*>(this) should be legal AFAIK (and doesn't need a vtable)
>
> It works in some cases, but it will fail the
> smart_ptr/test/shared_from_this_test.cpp test for example.

You are right. Which makes the optimization possible only for cases
where enable_shared_from_this<T> is not a virtual base class of T. What
do you (and others) think about branching enable_shared_from_this<T>
into two classes:

  low_overhead_enable_shared_from_this<T>

and

  feature_rich_enable_shared_from_this<T>

Yes, the names are crap, we need better ones :) Apart from that, I think
it might be worth it. The first one would be the classic one plus the
limitation you pointed out for virtual base classes, with an overhead of
just 4 bytes, while the second one is the trunk version which offers a
lot more features but currently has an overhead of 4 pointers, a vtable
and a bool.

Note that I don't think that one of the classes is "better" than the
other, I just think that each class has valid use cases which can not be
satisfied by the other class.

Regards, Daniel


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