fork(1) download
  1. #include <iostream>
  2. #include <initializer_list>
  3.  
  4. // The actual function
  5. template <class... TClasses>
  6. void allocateAll() {
  7. std::initializer_list<int>{(TClasses::allocate(), void(), 0)...};
  8. }
  9.  
  10. struct C1 { static void allocate() { std::cout << "allocated C1\n"; } };
  11. struct C2 { static void allocate() { std::cout << "allocated C2\n"; } };
  12. struct C3 { static void allocate() { std::cout << "allocated C3\n"; } };
  13.  
  14. int main()
  15. {
  16. allocateAll<C1, C2, C3>();
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
allocated C1
allocated C2
allocated C3