Chapter 8: Utility Classes

The C++ Standard Library includes an assortment of utility classes designed for specific tasks. Some are common, and you've probably seen many of these classes in other recipes in this book.

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 ...

Get C++20 STL Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.