Skip to content

Instantly share code, notes, and snippets.

@onqtam
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onqtam/de7eec2f590aec0199ce to your computer and use it in GitHub Desktop.
Save onqtam/de7eec2f590aec0199ce to your computer and use it in GitHub Desktop.
#include <iostream>
template <class F, class... Args>
void for_each_argument(F f, Args&&... args) {
[](...){}((f(std::forward<Args>(args)), 0)...);
}
void print(int in) {
std::cout << in << std::endl;
}
int main(int argc, char** argv) {
for_each_argument(print, 1, 2, 3);
return 0;
}
// prints:
// 3
// 2
// 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment