Using templates for logic

I have a template class that follows different logic paths depending on the class used for the template. I am not sure on how to check if a type is one or the other. Sizeof is not a great option since classes could be the same size. And also the classes are not the common types.

Any help is appreciated.

kinda the example...
1
2
3
4
5
6
7
8
9
10
11
12
13
template <class T>
class Test{
public:
  int a;

  Test(){
    //pseudo code
    if T == MyInputDevice
      a = 5
    if T == MyD3D
      a = 6 
  }
};

Last edited on
closed account (1yR4jE8b)
Can't you just use Template Specialization?

1
2
3
4
5
6
7
8
9
template<>
Test<MyInputDevice>::Test(){
    a = 5;
}

template<>
Test<MyD3D>::Test(){
    a = 6;
}
+1 darkestfright
Thanks, didn't know you could do this.
Topic archived. No new replies allowed.