Container Adaptors
Additional container classes that are provided by the STL library are container adaptors. Container adaptors provide constrained access policies on top of the containers we have looked at in this chapter.
Container adaptors have a template parameter that the user can provide to specify the type of container to wrap:
Stack
The stack container implements the LIFO access policy, where the elements are virtually stacked one on the top of the other so that the last inserted element is always on top. Elements can only be read or removed from the top, so the last inserted element is the first that gets removed. A stack is implemented using a sequence container class internally, which is used to store all the elements and emulate the stack behavior.
The access pattern of the stack data structure happens mainly through three core member functions: push(), top(), and pop(). The push() function is used to insert an...