fork(10) download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. template<typename T>
  5. void create()
  6. {
  7. std::cout << "create called with " << typeid(T).name() << std::endl;
  8. }
  9.  
  10. template<typename...>
  11. struct caller;
  12.  
  13.  
  14. template<typename T, typename...Rest>
  15. struct caller<T, Rest...>
  16. {
  17. static void call()
  18. {
  19. create<T>();
  20. caller<Rest...>::call();
  21. }
  22. };
  23. template<>
  24. struct caller<>
  25. {
  26. static void call()
  27. {
  28. }
  29. };
  30.  
  31. template<typename...classes>
  32. void createObject(){
  33. caller<classes...>::call();
  34. }
  35.  
  36. int main()
  37. {
  38. createObject<int,float, short>();
  39. }
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
create called with i
create called with f
create called with s