I have a set of types related to a one to one relationship, for example:
TypeA ---> Type1 TypeB ---> Type2 TypeC ---> Type3
I know this relation at compile time.
Then I have a template class that depends on these two types:
template<class T1,class T2> class MyClass { T1 foo; T2 bar; };
Now the user of my library will print something like:
MyClass<TypeA,Type1> x;
This is inconvenient because there is a dependency between the two types, and it should be enough for the user to specify only the first type.
In addition, mixing the two types should not be possible:
MyClass<TypeA,Type2> y;
I am not very familiar with meta-programming of templates, I got the impression that this is a doable task, but I could be wrong.
The number of types involved is large, but I am happy to run a script to generate the code, if necessary.
Do you know if this is possible, or am I wasting my time? Do you have any ideas to point me in the right direction?
source share