|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-04-26 11:08:00
I had this disagreement with Thorsten in Lillehammer (or was it
Oxford?) but he was unimpressed with my arguments. I was wondering
what Boost as a whole would think:
My Thesis: the library should support copying and assignment of
pointer containers using the usual copy/assignment syntax, rather
than only allowing a copy via a clone() function.
Rationale: Not being able to copy and assign pointer containers is an
arbitrary restriction that limits usefulness and expressivity. The
argument Thorsten gives against copyability is that the elements
would have to be clone()d rather than copied, which is expensive
because there's a dynamic allocation per element. I don't get it;
we don't arbitrarily prohibit copying of std::vector<std::string>
even though that incurs a dynamic allocation per element.
Example: Consider std::pair<int,some_pointer_container>. Almost
nothing works. IIUC, it's not copyable, can't be initialized, and
can't be clone()d.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk