Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-04-26 12:09:13


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uacnl8qsf.fsf_at_boost-consulting.com...
|
| 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
^^^^^^^^

It was not an arbitrary choice. It makes little sense in my
world to give the same syntax to different semantics. Oh, I cannot copy X, but
if I
put it into ptr_vector, I can.

| 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.

There is another point: if the compiler don't do RVO and NRVO and/or
has to use assignment internally when handling vector< ptr_vector<T> >, it
*really, really* hurts
performance. I would like to see some benchmark that showed vector<
ptr_vector<T> >
would be as fast as ptr_vector< ptr_vector<T> >.

Big objects are not nice to copy IMO; they should however be movable.

-Thorsten


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