Useful C++ Classes

This page lists several classes from the C++ library that you may find useful at some point during CS 111. There are two popular Web sites for learning more about C++ classes: cppreference.com and cplusplus.com. The cppreference.com site is more precise and formal; it tends to be preferred by purists and experts. However, many people find cplusplus.com to be simpler and easier to understand, especially for people still learning C++. We provide links to both sites below; take your pick.

std::atomic

Used to define objects such as std::atomic that support well-defined atomic operations
[cplusplus] [cppreference]

std::condition_variable

Used in conjunction with std::unique_lock to put threads to sleep and wake them up again.
[cplusplus] [cppreference]

std::deque

A double-ended queue of objects of arbitrary type. Can insert and remove from both ends.
[cplusplus] [cppreference]

std::function

An object that encapsulates a call to a particular function with arbritrary parameters and return type.
[cplusplus] [cppreference]

std::map

A container that contains key-value pairs where there is an ordering among the keys. Supports both lookup by individual key and also range queries (find a group of objects in order of their keys). This class isn't quite as fast as std::unordered_map, but it supports ordering, which is not supported in std::unordered_map.
[cplusplus] [cppreference]

std::mutex

Basic locks; normally used in conjunction with std::unique_lock.
[cplusplus] [cppreference]

std::queue

Simple FIFO container for objects of any type. Most people find std::deque easier to use and more powerful.
[cplusplus] [cppreference]

std::string

Provides a variety of mechanisms for manipulating strings of text.
[cplusplus] [cppreference]

std::thread

Create system threads.
[cplusplus] [cppreference]

std::unique_lock

Acquires a std::mutex when constructed, automatically unlocks the mutex when the std::unique_lock is destroyed. This class is very useful to ensure that mutexes are always unlocked (e.g. when a method returns).
[cplusplus] [cppreference]

std::unordered_map

A container that contains key-value pairs with unique keys. Both keys and values can have aribtrary type. Provides fast lookup based on keys. The container is unsorted (there is no ordering among the elements)
[cplusplus] [cppreference]

std::vector

Expandable arrays of objects of any type. Provides fast access to any element using its index.
[cplusplus] [cppreference]