Language feature: Fold expressions

code

Variadic templates in C++11

The C++11 gave us the variadic templates, which allows us to send a variable number of parameters to a function. The way it is done is to call the function recursively, with the remaining parameters.

The problem with that is that we had to specify the stopping point (when we don’t have parameters).

Fold expressions

C++17 come to the rescue, allowing us to have only one function that do the job.

Example of pushing into a vector

Leave a comment

Your email address will not be published.