Into to the Standard Library
- This is a condensed version of chapters 16, 17 and 18
- I am covering this for multiple reasons.
- Objective 1, OODesing.
- Objective IIF2 - Standard
template librariesy.
- A great set of examples of most of what we will talk about.
- A great set of tools.
- Every C++ programmer should spend time studying this.
- The standard library in C++ is tightly controlled.
- As the name implies, it is required for standard compilers.
- It is officially set by the c++ standard committee.
- The Boost libraries
- Are not part of the official libraries
- But are a proving ground for potential library performance testing/proving/development.
- The library is all in namespace std.
- The library is roughly divided into two parts
- The container library
- The algorithm library.
- Both of these are huge
- You already know several features
- The library aims for consistency
- Similar things are done the same way.
- This means some additional learning, ie iterators.
- We will definitely pick up smart pointers later.
- Some things we will only cover if we need (random numbers).
- Some in passing (pair, tuple, ...)
- Some in more detail (vector, map, smart pointers, sort, find)
- I have found that if I am solving a problem and need a data structure/common algorithm it is most likely in the standard library.
- When I am not crushed, I do my best to learn a new standard library feature with every problem I solve.
- The library is constantly expanding
- It looks like the flat_map type will be added in 23.
- Containers:
- Classic data structures.
- But of a homogeneous type.
- But there is an
any
type, I don't know about it.
- The one we want: vector a dynamic array.
- list - a doubly linked list, never debug pointers again.
- array - standard array++
- queue/dequeue queue, double ended queue
- sets
- maps - we might look at this one, it would solve bug problems.
- Algorithms
- These are built to work with the containers.
- Most require a knowledge of iterators.
- Way too many to mention
- find, and several variations.
- shuffle - mix ump the items in a container if possible.
- is_sorted, sort, stable_sort - cool
- clamp, max, min, ...
- and MANY others.