The article directories

        • This column introduces
        • STL’s past and present lives
        • STL has more than just containers
        • STL in-depth study book recommendations

This column introduces

My STL column will be divided into three modules.

  1. The “Getting Close to STL” series of articles covers the basics of the STL, including getting started with the vectors, lists, and maps commonly used in the STL. My goal is to let friends who are new to STL get started quickly.
  2. “Into THE STL” series of articles, talking about the in-depth part of STL, mainly involving STL memory allocation, container source code analysis, algorithm source code analysis and other six blocks. What six pieces? More on that below). This series is for people who want to learn more about the STL, or traits that help them code. The benefits of learning more source code are obvious.
  3. “Embrace STL” series of articles, this module is about “into the STL” module learning C++ other technical support, after all, there is no certain C++ foundation, directly look at the source code analysis is very painful.

STL’s past and present lives

STL, though a set of libraries, is not just a set of libraries in the general impression, but an epoch-making invention with profound theoretical basis. It is a breakthrough in the history of software components.

STL was born in the C++ community in order to establish a set of standards for data structures and algorithms, reduce the coupling between them, and improve their interaction, flexibility, and independence.

STL is an open source project, so there are many versions. The SGI STL version I used in this column is very readable, both in terms of symbolic naming and coding style.


STL has more than just containers

For most people who have been exposed to STL, the impression of STL should be very good, but most people may simply draw the container and the entire STL equal sign, plus the algorithm, after all, we use STL commonly only two sets of header files. To be honest, THAT’s what I thought, too. STL provides six components, of which containers and algorithms are just a few:

Container, algorithm, iterator, functor, adapter, configurator.

What are these components? Don’t worry. Even if you do, read it again.

  • The container
  • Various data structures, such as vectors, lists, and maps, are used to store data.
  • algorithm
  • Various common algorithms such as: sort, add, delete and search. From the point of view of implementation, STL algorithm is a generic function.
  • The iterator
  • Surprisingly, iterators do not belong to containers, nor do they belong to algorithms.
  • The “generic pointer” acts as the “glue” between the container and the algorithm.
  • Native Pointers can be used as iterators, but iterators generally exist in the form of smart Pointers.
  • The simulation function
  • Behaves like a function and is, by implementation, a class or template class that overloads operator().
  • Function Pointers can be regarded as simulation functions in a narrow sense.
  • adapter
  • It’s a long story, something used to decorate containers, iterators, simulation functions.
  • configurator
  • Space configuration and management, if you want to understand the STL code, this will be a cornerstone of the general existence.

Take a look at a diagram of the six STL components working together:

STL in-depth study book recommendations

If it’s for applications, look no further than my “Approaching STL” series. I’m a lean, fun person, and my blog is not too long. If you want to learn more about STL, check out my “Into STL” series and “Embrace STL.” If you must read and have a certain foundation, recommend “STL source code analysis”

On the Internet to find the basic traditional version, this is simplified with directory, picture quality is good.