fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. enum class Action {A, B};
  5.  
  6. template <Action a>
  7. void applyAction()
  8. {
  9. std::cout << "Action " << (int)a << std::endl;
  10. }
  11.  
  12. template <Action... as>
  13. void applyActions() {
  14. using do_= int[];
  15. (void)do_{0, (
  16. applyAction<as>()
  17. ,0)...,0};
  18. }
  19.  
  20. void foo() {
  21. applyActions<Action::A, Action::B>();
  22. }
  23.  
  24. void bar() {
  25. applyActions<Action::B, Action::A>();
  26. }
  27.  
  28.  
  29.  
  30. int main() {
  31. foo();
  32. bar();
  33. return 0;
  34. }
Success #stdin #stdout 0s 4340KB
stdin
Standard input is empty
stdout
Action  0
Action  1
Action  1
Action  0