Sequence containers
The STL supports quite an interesting variety of sequence containers. Sequence containers store homogeneous data types in a linear fashion, which can be accessed sequentially. The STL supports the following sequence containers:
- Arrays
- Vectors
- Lists
forward_list
- deque
As the objects stored in an STL container are nothing but copies of the values, the STL expects certain basic requirements from the user-defined data types in order to hold those objects inside a container. Every object stored in an STL container must provide the following as a minimum requirement:
- A default constructor
- A copy constructor
- An assignment operator
Let's explore the sequence containers one by one in the following subsections.
Array
The STL array container is a fixed-size sequence container, just like a C/C++ built-in array, except that the STL array is size-aware and a bit smarter than the built-in C/C++ array. Let's understand an STL array with an example:
#include <iostream> #include <array>...