Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-19 06:16:17

From: "Navi Singh" <singh_at_[hidden]>
> Peter Dimov:
> I am probably talking thru my hat. Don't know all the issues involved,
> here is a suggestion. Is the following a bad idea? If not, is it
> to provide a such a functionality in your smart ptr library.
> Consider two classes, one derives from counted base and one doesn't.
> class test1
> {
> };
> class test2 : public boost::counted_base
> {
> };
> As a rule, everyone will use a ptr template (defined later in this post).
> The ptr template will either be a shared_ptr or an intrusive_ptr template
> based on whether the class in consideration derives from counted_base or
> not.
> ptr<test1> t1(new test1); // ptr is a shared_ptr.
> ptr<test2> t2(new test2); // ptr is an intrusive ptr.

You could do that, but why not simply restating the above as:

shared_ptr<test1> t1(new test1);
intrusive_ptr<test2> t2(new test2);

The comments are no longer necessary. :-)

Boost list run by bdawes at, gregod at, cpdaniel at, john at