Last active
August 29, 2015 14:14
-
-
Save onqtam/de7eec2f590aec0199ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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