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?
m.s. :
CONFIG1 and CONFIG3 are the same type, therefore your specialization will fail with\n\nerror: redefinition of 'struct MyClass<Config<x, y, z> >'\nstruct MyClass<CONFIG3>{};\n\n\nYou can use inheritance to create a new type:\n\nusing CONFIG1 = Config<x, y, z>;\nstruct CONFIG3 : CONFIG1{}; \n\n\nLive example: https://ideone.com/4GrlaW",
2015-05-31T14:19:41
Xiaotian Pei :
CONFIG1 and CONFIG3 are the same type. If you doubt, you can verify with std::is_same",
2015-05-31T14:18:01