Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Variadic templates example: sizeof for parameter pack
#include <iostream>
using namespace std;
void sayIt() {
// Does nothing
}
template <typename T, typename... Ts>
void sayIt(T t, Ts... ts) {
cout << t;
if (sizeof...(ts))
cout << " (" << sizeof...(ts) << " more messages)";
cout << endl;
sayIt(ts...);
}
int main() {
cout << "Example 3: Output" << endl;
sayIt("Message 1", "Message 2", "Message 3", "Message 4");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.