I store a configuration as a type:
using CONFIG1 = Config<x, y, z>;
using CONFIG2 = Config<a, b, c>;
using CONFIG3 = Config<x, y, z>;
For each config, there's a class template specialization, which does some more configuration work:
template <class CONFIG>
MyClass;
template <>
MyClass<CONFIG1>{...}
template <>
MyClass<CONFIG2>{...}
template <>
MyClass<CONFIG3>{...}
Now, as you see, CONFIG1
happens to have the same definition as CONFIG3
.
The question is:
Which specialization will be taken for CONFIG1
and CONFIG3
, or: When is a type equal? Is it it's name or it's actual content?
If it's the actual content, how can I achieve that CONFIG1
and CONFIG3
actually invoke different specializations?
CONFIG1
and CONFIG3
are the same type, therefore your specialization will fail with
error: redefinition of 'struct MyClass<Config<x, y, z> >'
struct MyClass<CONFIG3>{};
You can use inheritance to create a new type:
using CONFIG1 = Config<x, y, z>;
struct CONFIG3 : CONFIG1{};
Live example: https://ideone.com/4GrlaW