What's an adapter?
Alberto last edited by
I've got a clear book on STL. adapter And I went straight to the search to cover this question and found nothing useful.
The book says that this is the implementation of one type of container by another type of container. There's not much to understand.
Tell me what it is. adapter STL.
I want to start with a small foreword: there is no STL in C++, there is a standard library, and this term should be followed. The term STL used to refer to a standard library, but now it's considered a moveton.
What's an adapter? It's basically a well-established patter that comes to us from the real world. We take one thing and adapt it to new conditions through another. Absolutely not.
What do you mean in the book? There's probably a talk about the glass and the other containers. Why are they adaptors? Because there's a lot of containers inside of themselves, like,
std::dequeand adapt their interface to another interface♪ For example,
pop_backbut there's no need for such a steep operation, there's a need for three operations.
push♪ But all these operations are carried out through related operations.
std::vectorwhich hides in the subsoil
std::stack♪ That's why.
stackThey don't stand as an independent container.
In other words, the adapter is a concept that goes far beyond the standard library C+++ and, in general, can be ignored by learning C++, that is, whether the container is an adapter or not a key part. It's interesting to know, but not much.