can templates be specialized based on enum values
#include <type_traits>
template<typename T, typename = void>
struct Specialize
{
};
template<typename T>
struct Specialize<T, typename std::enable_if<std::is_enum<T>::value>::type>
{
void convert() { }
};
enum E
{
};
int main()
{
Specialize<E> spec;
spec.convert();
}
// My doubt: is below code valid? if not how to achieve this?
enum E
{
E1,
E2
};
int main()
{
Specialize<E, E1> spec;
spec.convert();
}
This is a follow-up question to the answer to the below question.
How can I partially specialize a class template for ALL enums?
I have copy pasted the code from the answer to the question linked above.
I am getting the following error with my changes.
error: type/value mismatch at argument 2 in template parameter list for _template
Aucun commentaire:
Enregistrer un commentaire