Is std::string part of the STL?

孤街醉人 提交于 2019-11-28 18:36:10
Lightness Races in Orbit

No, not really. And yes, kind of.

There are varying definitions of "the STL", including:

  • The actual HP/SGI STL, the original library, parts of which the C++ Standard Library was based on. They included containers, iterators and algorithms. Strings were not a part of this.

  • The parts of the C++ Standard Library that were based on the SGI STL library: containers, iterators and algorithms. Still no strings.

  • All of the C++ Standard Library. This definition has absolutely no grounding in logic or reality though, if followed, std::string would be included.

Note that the actual STL has developed since C++ was standardised (some 13 years ago, remember), and they've backwards-adopted some of the stuff that went into the standard, like strings. This does not mean that they were originally there in 1998... but they are there now for "compatibility" reasons.


Summary

The STL was containers, algorithms and iterators.

Strings and streams were adopted for C++98, then backwards-adopted for the modern SGI STL.

Whether strings are "part of the STL" or not depends on whether you follow logic and reason, or call the standard library "STL".

Hope this helps.

There is no real answer to this. On one hand, std::string was developed entirely independently from the other containers. On the other hand, it's had enough added on to meet all the requirements of a random-access container. Whether you choose to classify that as part of "STL" or not is entirely up to you -- in the end, it just points to the fact that "STL" lacks a single, agreed-upon definition, and the chances of it suddenly gaining a clear meaning is remote (to put it nicely).

IOW, "STL" is a lousy abbreviation to use because people use it to mean at least three different things -- but, unfortunately, there's no better abbreviation around with a better defined meaning either, so STL remains in use and will probably continue to do so (and continue to obstruct communication) indefinitely.

It is part of STL indeed. And std::string is just basic_string typedef. It is container, specialized ( not in c++ "specialization" meaning :) ) for data storage with string semantics. No idea about Stepanov though. Worth mentioning is that STL is "Standard Template Library", not only container subpart. That includes algorithms, streams and some traits.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!