Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2005-08-18 03:36:56

----Original Message----
From: Thorsten Ottosen [mailto:nesotto_at_[hidden]]
Sent: 17 August 2005 17:19
To: boost_at_[hidden]
Subject: Re: [boost] Propose adding Clone Smart Pointer (clone_ptr) to
the boost library

> "Martin Bonner" <martin.bonner_at_[hidden]> wrote in message
>> B) Under what circumstances is a std::container<clone_ptr<T> >
>> better than a boost::ptr_container<T>?
> I won't discuss if it's better,
Perhaps "better" is too loaded a word. What I meant is that both allow a
user to implement a container of heterogeneous objects. The documentation
needs to explain when the user should choose one over the other (they must
offer different trade-offs).

I was about to say "Just as the documentation compares and constrasts
boost::any and boost::variant." However it turns out that it doesn't! It
would be useful if it did.

> but its certainly very different
> in thefollowing sense:
> - ptr_container<T> discourages cloning of T objects and doesn't
> require it
> - vector<clone_ptr<T>> requires cloning of T objects (and hence
> encourages
> it)
> If T is an OO-type with virtual functions, I find that identity often
> matters (performance and logical-wise) and hence that excessive
> cloning is best avoided.
I agree. I think that clone_ptr is designed for a rather small niche, and I
can't see myself ever needing it ... but that doesn't mean it couldn't be
useful to somebody.

Martin Bonner
Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ,
ENGLAND Tel: +44 (0)1223 441434

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