language: C++11 (gcc-4.7.2)
date: 334 days 1 hour ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <typeinfo>
 
template<typename T>
void create()
{
   std::cout << "create called with " << typeid(T).name() << std::endl;
}
 
template<typename...>
struct caller;
 
 
template<typename T, typename...Rest>
struct caller<T, Rest...>
{
     static void call()
     {
        create<T>();
        caller<Rest...>::call();
     }
};
template<>
struct caller<>
{
     static void call()
     {
     }
};
 
template<typename...classes>
void createObject(){
      caller<classes...>::call();
}
 
int main()
{
      createObject<int,float, short>();
}