C++ Strings under the STL?

This is a discussion on C++ Strings under the STL? within the C++ Programming forums, part of the General Programming Boards category; I had the impression that C++ strings arent implemented as a template class, so they dont come under the standard ...

  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,441

    C++ Strings under the STL?

    I had the impression that C++ strings arent implemented as a template class, so they dont come under the standard template library.

    A little googling appears to confirm this.
    http://www.msoe.edu/eecs/ce/courseinfo/stl/

    However, I've also seen references to "STL strings", which apparently refer to C++ strings, i.e. those using <string>

    Are C++ strings considered as part of the STL then?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,649
    <string> is part of the standard template library.

    gg

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088

    Re: C++ Strings under the STL?

    Originally posted by laserlight
    I had the impression that C++ strings arent implemented as a template class, so they dont come under the standard template library.
    The STL string class is implemented as a template class, its just the string itself is a specialization for ASCII chars. It is basically defined as:

    typedef basic_string<char, char_traits<char>, allocator<char> > string;

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    std::string is defined to be a specialization of basic_string in the standard -- lib.string.classes
    Code:
      namespace std {
      // Lots of stuff defining basic_string and character traits....
    
        typedef basic_string<char> string;
        typedef basic_string<wchar_t> wstring;
      }
    That said, "Standard Template Library" is sort of an undefined term. I don't think it's actually part of the standard, and I've never heard it used in a manner distinguishable from "C++ Standard Library".
    Callou collei we'll code the way
    Of prime numbers and pings!

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    Quote Originally Posted by QuestionC View Post
    That said, "Standard Template Library" is sort of an undefined term.
    Well, no so undefined... http://www.cppreference.com/cppstl.html
    Have you tried to google it?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  6. #6
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Soo....

    laserlight self-quotes, you click the link, and respond to the question? (Unfortunately, I think laserlight already knows the answer.)

    Perhaps in a few years you'll look back on this day as laserlight did... history is doomed to repeat itself, it seems.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The STL was a library developed by HP, before the C++ standardization. It contained containers, algorithms, and iterators that were the glue between them.

    When C++ was standardized, the classes from the STL were made part of the C++ standard library, and the std::string class was designed to be similar to the containers in interface. However, as far as the standard is concerned, there is no such thing as the STL. QuestionC is quite right. STL is sometimes used to refer to:
    1) the whole C++ standard library,
    2) just the part that derives from the original STL, i.e. containers, algorithms and iterators or
    3) that part, plus std::string.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Quote Originally Posted by vart View Post
    Well, no so undefined... http://www.cppreference.com/cppstl.html
    Have you tried to google it?
    Doh, what am I doing, looking at the ISO working papers when cppreference.com is the real standard?

    Not to be mean, but that link really isn't even a good definition for "What is the STL".

    Anyhow, who decides what is/isn't part of the STL? Is SGI the de facto authority on this? It just seems to me there's bound to be some gray area in defining the boundaries.
    Callou collei we'll code the way
    Of prime numbers and pings!

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,441
    Anyhow, who decides what is/isn't part of the STL? Is SGI the de facto authority on this? It just seems to me there's bound to be some gray area in defining the boundaries.
    The basis of the STL is a concept: separate generic algorithms and generic containers such that they can be mixed and matched. As a library, the STL is the original expression of that idea in C++, using C++ templates. So, it was Stepanov, Lee and their associates who decided what was part of the STL, and that is that. Under such a historical interpretation, std::string is not part of the STL.

    Of course, if we look at it as a term that is evolving in usage, then CornedBee's treatment of the term is probably best. After all, a new generic container added to the standard library could be seen (unofficially with respect to the standard) as being part of the STL portion of the standard library, even though its provenance is actually different.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by QuestionC View Post
    That said, "Standard Template Library" is sort of an undefined term. I don't think it's actually part of the standard, and I've never heard it used in a manner distinguishable from "C++ Standard Library".
    Prior to 1998, there was no "C++ Standard Library", but there was the STL. In 1998 with the new standard, there became a C++ Standard Library which included the STL, but not ONLY the STL -- for example, the entirety of the C90 Standard Library, plus revisions of the pre-standard C++ libraries (iostream, etc) are all the Standard Library.

    When people speak of STL now, they're talking about the portion of the Standard Library which is derived from the STL, and not the portions which are from the C language, or the early C++ language. That is, the template-driven parts like vector<> and list<> and the like.

    STL is a subset of Standard Library.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 02:24 PM
  2. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:34 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21