Article View: comp.std.c++
Article #3987Re: strings as stl container
From: Nico Josuttis
Date: Thu, 11 Apr 1996 08:09
Date: Thu, 11 Apr 1996 08:09
49 lines
2632 bytes
2632 bytes
In article <4jvdnd$c9c@hermes.synopsys.com>, Joe Buck <jbuck@Synopsys.COM> wrote: >Nico Josuttis <nico@bredex.de> writes: >>Due to the fact that strings have iterator support, >>the could be used as stl container. > >Correct. > >>But two things are missing: >> - push_back() >> - clear() > >No, these are not needed. clear() is required for sequenceable containers, push_back() is optional for sequenceable containers but would make many sense. So for the others vector like operations (pop_back(), front(), back()). > >>These are fundamental operations, that the corresponding "normal" >>container, namely vector, has. > >The documentation I have does not list clear as a member of vector. > Oh yes, it does, see 23.2.5.6 in vector class structure. >>Especially push_back() would be essential to use insert iterators >>for strings. > >No, this isn't true. You need push_back to use back_insert_iterator, >but insert_iterator only needs insert, which string does have. > But insert_iterators are VERY dangerous for sequenceable collections. They invalidate themself if the position parameter is not end(). So having push_back() would be safer and of course more convenient (otherwise there is no sense to have it for vectors either). -- Nico address: BREDEX GmbH, Nicolai Josuttis email: nico@bredex.de Fallersleber-Tor-Wall 23 phone: +49 531 24330-0 D-38100 Braunschweig fax: +49 531 24330-99 Germany --- [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<199604110801.KAA01575@bredex.bredex.de>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<199604020907.LAA06972@bredex.bredex.de> <4jvdnd$c9c@hermes.synopsys.com>Show Full Headers
Complete Article Headers
From: Nico Josuttis <nico@bredex.de> Message-ID: <199604110801.KAA01575@bredex.bredex.de> X-Original-Date: Thu, 11 Apr 1996 10:01:04 +0200 Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 11 Apr 96 08:09:01 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: strings as stl container References: <199604020907.LAA06972@bredex.bredex.de> <4jvdnd$c9c@hermes.synopsys.com> Reply-To: nico@bredex.de Organization: Bredex GmbH Apparently-To: jbuck@Synopsys.COM Apparently-To: nico@bredex.de Apparently-To: std-c++@ncar.ucar.edu X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMWy+NeEDnX0m9pzZAQGkeQGAlPR/cGRi4lqz5gIniGqw6ElZgh1/lf7O iS5ylgOsRVjzo2shwsAmXJce9p0ux2xV =9l/g