For performance reasons, I'm using a templated class with an enum instead of relay on inheritance (It is not an option).
At this point I have something like:
typedef enum { A, B, C, D } QueueType;
template <QueueType T> class Queue {
Queue(int a){...} // only usable when T = A
Queue(unsigned a, unsigned b){...} // only usable when T = B || T = C
Queue(somestruct z){...} // only usable when T = B || T = C
//other constructors
}
Now I'm using an annoying amount of ifs/switches over T and rising exceptions if an incompatible constructor is called for a defined T.
What I want is to use std::enable_if or equivalent to prevent throwing exceptions on constructor and detect on compilation time such kind of errors.
I've tried many stack-overflows and foreign sites std::enable_if examples, but I can barely understand what I'm really doing and I always end on a compilation error.
Thanks in advance and sorry for asking for a probably trivially answered question. I'm noob with templates.
Environment: Linux GCC 8 and c++14 Restrictions: Maximal performance with no virtual methods.