Chapter Overview

Get an idea of what we'll cover in this chapter.

We'll cover the following...

The C++ Standard Library includes an assortment of utility classes designed for specific tasks. Some are common, and we've probably seen many of these classes in other recipes in this course. This chapter covers a broad range of utilities, including time measurement, generic types, smart pointers, and more, in the following recipes:

  • Manage optional values with std::optional
  • Use std::any for type safety
  • Store different types with std::variant
  • Time events with std::chrono
  • Use fold expressions for variadic tuples
  • Manage allocated memory with std::unique_ptr
  • Share objects with std::shared_ptr
  • Use weak pointers with shared objects
  • Share members of a managed object
  • Compare random number engines
  • Compare random number distribution generators