enum MyEnum{
task1 = 0,
task2
};
// template<MyEnum T> works
template<class T>
void fun(){
}
int main(){
fun<MyEnum::task1>();
// fun<int>(); works
}
How to create template type of enum
When I try to create a template out of enum I get error saying no matching function for call to ‘fun()
Why does the int work by not enum type?
When I do template<MyEnum T> it works but I dont understand why.
MyEnum::task1is a value.MyEnumis a typetemplate<MyEnum T>works then?typenameorclassyou are asking for a type. If you have a type, then you are asking for a value.template<MyEnum T>is a non-type template parameter. Similar totemplate<int I>.