🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Robert DiFalco Sat, 20 Jan 1996 16:22
Re: Enhanced container functionality
#3092
Author: Robert DiFalco
Date: Sat, 20 Jan 1996 16:22
42 lines
2713 bytes
"Eugene Radchenko" <eugene@qsar.chem.msu.su> writes:
> Hi!
> Having used the STL for some time, I have come to greatly missing some nice
> things (and eventually derived Vector<T> from vector<T>, adding them along
> with persistence support).
> First, it is the ability to (easily) flush the entire container
>   void erase() { erase(begin(), end()); }
> Second, it is the 'post-factum' equivalents to some constructors
>   void assign(size_type n, T t = T());
>   void assign(const_iterator first, const_iterator last);
> etc. - putting the container into the same state as the one it would have
> after the respective constructor (with the possible exception of more
> reserved space available).
> I think these features deserve inclusion.
> 

I'd have to disagree. I've often found operations like Erase, 
Clear, Assign and such as somewhat strange. Essentially, when
you say "assign", you are saying give me a new container. If 
this is the case, why not just create a new container? Same 
with Erase. Why would you "erase" the entire contents of a 
container if not to create a new one? Assigning or erasing
specific items is different since then you are just changing
the container rather than recreating it. The only reasons I
can see for wanting Erase and Assign would be efficiency where
one would rather erase all the items of the current container
and assign new ones rather than to simply create a new 
container. This seems semantically impure to me and I'd just
instantiate a new one then resuse a current container that
is no longer needed around. I would imagine the relative
efficiency metrics between the two are about the same. You can
even take this sort of thinking to things like ranges. Should
one really be able to redefine the Upper or Lower bound of 
a range? Probably not, ranges are small and you are probably
just better of creating a new one. For example, check out
the differece between "a" and "b" below:



[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads