fork 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 typelist{};
  12.  
  13. template<typename T, typename ... Rest>
  14. void call(typelist<T,Rest...>)
  15. {
  16. create<T>();
  17. call(typelist<Rest...>());
  18. };
  19.  
  20. void call(typelist<>) { }
  21.  
  22. template<typename...classes>
  23. void createObject(){
  24. call(typelist<classes...>());
  25. }
  26.  
  27. int main()
  28. {
  29. createObject<int,float, short>();
  30. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
create called with i
create called with f
create called with s