What's the difference between “STL” and “C++ Standard Library”?

前端 未结 7 917
忘了有多久
忘了有多久 2020-11-21 07:37

Someone brought this article to my attention that claims (I\'m paraphrasing) the STL term is misused to refer to the entire C++ Standard Library instead of the part

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-21 07:45

    There is no one answer that's really correct. Alexander Stepanov developed a library he called STL (working for HP at the time). That library was then proposed for inclusion in the C++ standard.

    That basically "forked" development. The committee included some parts, rejected others completely, and redesigned a few (with Alexander's participation). Development of the original library was later moved to Silicon Graphics, but continued separately from the C++ standard library.

    After those pieces were added to the standard library, some other parts of the standard library were modified to fit better with what was added (e.g., begin, end, rbegin and rend were added to std::string so it could be used like a container). Around the same time, most of the library (even pieces that were completely unrelated) were made into templates to accommodate different types (e.g., standard streams).

    Some people also use STL as just a short form of "STandard Library".

    That means when somebody uses the term "STL" they could be referring to any of about half a dozen different things. For better or worse, most people who use it seem to ignore the multiplicity of meanings, and assume that everybody else will recognize what they're referring to. This leads to many misunderstandings, and at least a few serious flame-wars that made most of the participants look foolish because they were simply talking about entirely different things.

    Unfortunately, the confusion is likely to continue unabated. It's much more convenient to refer to "STL" than something like "the containers, iterators, and algorithms in the C++ standard library, but not including std::string, even though it can act like a container." Even though "C++ standard library" isn't quite as long and clumsy as that, "STL" is still a lot shorter and simpler still. Until or unless somebody invents terms that are more precise (when necessary), and just as convenient, "STL" will continue to be used and confusion will continue to result.

提交回复
热议问题