9 Parameter packs and std::visit

This chapter covers

  • Practicing with algorithms and execution policies
  • Template parameter packs
  • The std::visit method and Overload pattern
  • Mutable lambdas
  • Extra practice with variants, std::format, and ranges

We have used parameter packs (the three dots in a template) several times now, but we have not paused to understand how they work. In the final chapter, we will fill in the dots, as well as practice many things we have learned so far. We will generate triangle numbers and briefly consider some of their properties. Triangle numbers crop up in various places (e.g., counting how many handshakes would happen in a group of people if everyone shakes hands). Because we started with Pascal’s triangle, returning ...

Get Learn C++ by Example 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.