Chapter 8. Utility Classes
In this chapter, we will cover the following recipes:
- Converting between different time units using
std::ratio
- Converting between absolute and relative times with
std::chrono
- Safely signalizing failure with
std::optional
- Applying functions on tuples
- Quickly composing data structures with
std::tuple
- Replacing
void*
withstd::any
for more type safety - Storing different types with
std::variant
- Automatically handling resources with
std::unique_ptr
- Automatically handling shared heap memory with
std::shared_ptr
- Dealing with weak pointers to shared objects
- Simplifying resource handling of legacy APIs with smart pointers
- Sharing different member values of the same object
- Generating random numbers and choosing the right random number engine
- Generating random numbers and letting the STL shape specific distributions