Boost logo

Boost :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-07-28 23:42:55


> > typedef counted<YourFancyClass> YourFancyClassEx;
> > shared_ptr<YourFancyClassEx> = new YourFancyClassEx;

> Well:
> - counted<YourFancyClass> will have to rewrite every constructors of
> YourFancyClass. Will begin to be problematic for QListViewItem for
example:
> many long constructors.
It's not a problem at all. struct counted as I mentioned will have templated
forwarding constructors (using BPPL you could achieve as much arguments as
you need).

> - You won't be able to assign shared_ptr<YourFancyClassParentEx> =
> shared_ptr<YourFancyClassChildEx>. The counter won't be at the same
offset.
If you going to involve runtime polymorphism. it would be strange to be
bothered by the small penalty for using of non intrusive reference counting
(that also could be negligible with use of some kind of smart allocator for
counters. something like pool_alloc)

> - Will be painful if you want to apply your technique to every widget of
> the QT library i.e. an existing library with hundreds of heavy class with
> complex constructors often.

Not at all. Since you writing one wrapper template that will work for all
your classes. It could be(?) slightly inconvenient for those who use to use
non-wrapped classes , but here we meet efficiency/usability tradeoff. I
don't think it worse that you are proposing.

Gennadiy.


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