I would be surprised to see that the compiler really knows the std containers and calls their methods without my explicit request. If that were the case, imagine how the compiler logic should be augmented whenever a new library module is released!
It would be interesting, however, to find out that some C ++ compilers have some knowledge of the standard library.
EDIT: Well, I found an example of this knowledge: for loops based on C ++ 11 ranges, std :: begin and std :: end are used for ranges.
In any case, we programmers must really understand what we are writing and find out ways to optimize it. The compiler should simply translate our instructions, applying only small (but significant) optimizations (for example, embedding, copying, etc.).
source share