I am aware of the fact it is not possible to specialize an alias template.
The fact is that I often find the following recurring pattern:
template<class Code, Code code>
struct BaseStruct;
enum MyCode {A,B,C};
template<MyCode code>
using MyStruct = BaseStruct<MyCode, code>;
template<> // Error not possible
struct MyStruct<MyCode::A>
{
};
template<> // Ok but too long to write
struct BaseStruct<MyCode, MyCode::A>
{
};
Sometimes I have to write many specializations and BaseStruct can have other template parameters or with maybe have a long name, so the ideal would be to use an alias and then specialize it.
What do you guys do in this situation? I'd rather not using macros or other ways that introduce overhead.
PS I'm using c++11
Aucun commentaire:
Enregistrer un commentaire