Topic: push_back and basic_string


Author: kanze@gabi-soft.de
Date: 2000/01/16
Raw View
Fausto Fabbioni <fabbioni@freelance.it> writes:

|>  Bjarne Stroustrup wrote:

|>  > Ahn Ki-yung <kyagrd@chiak.kaist.ac.kr> writes:

|>  > > Is push_back, and pop_back member of basic_string ?

|>  > push_back() is, pop_back() isn't.

|>  > > In The C++ Programming Language 3rd Edition,
|>  > > Chapter 6 (p115) and Chapter 20 (p), there is an example
|>  > > using push_back member of the string type variable.

|>  > > Is this Standard ?

|>  > Yes. I don't describe proprietary extensions. Unless explicitly stated,
|>  > if 'it' is in "The C++ Programming Language (3rd Edition)" then 'it' is
|>  > in the standard. (See http://www.research.att.com/~bs/3rd_issues.html
|>  > for open issues).

|>  Sorry. But I don't understand why push_back is and pop_back ins't.

Simply because we (the French delegation) didn't think of it.  Neither
was originally in the standard; push_back was added in one of the last
meetings, because the French comments on the CD2 mentioned that it was
missing.

I'm not sure that pop_back would have been accepted, even if we had
mentioned it.  The basic justification for push_back was that the exact
functionality was already there, in the form of append; it was just
oversight not providing the STL compatible name.  Off hand, I don't see
what std::string function pop_back would map to.

--
James Kanze                         mailto:James.Kanze@gabi-soft.de
Conseils en informatique orient   e objet/
                  Beratung in Objekt orientierter Datenverarbeitung
Ziegelh   ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Niklas Mellin <nimel@my-deja.com>
Date: 2000/01/17
Raw View
In article <867lh9u5x9.fsf@gabi-soft.de>,
  kanze@gabi-soft.de wrote:

[...]

>
> I'm not sure that pop_back would have been accepted, even if we
> had mentioned it.  The basic justification for push_back was
> that the exact functionality was already there, in the form of
> append; it was just oversight not providing the STL compatible
> name.  Off hand, I don't see what std::string function pop_back
> would map to.

Perhaps:
str.erase(--str.end());
or
str.resize(--str.size());

/Niklas Mellin


Sent via Deja.com http://www.deja.com/
Before you buy.


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Fausto Fabbioni <fabbioni@freelance.it>
Date: 2000/01/11
Raw View
Bjarne Stroustrup wrote:

> Ahn Ki-yung <kyagrd@chiak.kaist.ac.kr> writes:
>
> > Is push_back, and pop_back member of basic_string ?
>
> push_back() is, pop_back() isn't.
>
> > In The C++ Programming Language 3rd Edition,
> > Chapter 6 (p115) and Chapter 20 (p), there is an example
> > using push_back member of the string type variable.
> >
> > Is this Standard ?
>
> Yes. I don't describe proprietary extensions. Unless explicitly stated,
> if 'it' is in "The C++ Programming Language (3rd Edition)" then 'it' is
> in the standard. (See http://www.research.att.com/~bs/3rd_issues.html
> for open issues).

Sorry. But I don't understand why push_back is and pop_back ins't.
In the standard document on String Library chapter the push_back
is point out only on declaration of class, but it isn't described
on modifiers paragraph 21.3.5 why.

It seems a mistake.
I believe that pop_back can be more helpful as push_back.

Sorry for my bad english.

Fausto Fabbioni


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]