...

/

Examples - Fold Expression

Examples - Fold Expression

This lesson focuses the implementation of the Fold Expression Templates.

We'll cover the following...

Here’s a quite nice implementation of a printf using folds P0036R04

Press + to interact
#include <iostream>
using namespace std;
template<typename ...Args>
void FoldPrint(Args&&... args)
{
(cout << ... << forward<Args>(args)) << '\n';
}
int main()
{
cout << "Your Arguments = ";
FoldPrint("hello", 10, 20, 30);
}

​However, the above FoldPrint will ...