vendredi 8 janvier 2021

A template class that only accepts enum type arguments?

Given this pseudo stub class:

template<class T>
MyClass
{
 std::map<T,std::string> mContents;
};

Is there a way to only allow T to be an enum type? I was trying to understand what was discussed in this question and linked pages, whether I can use std::enable_ifwith std::is_enum but I can't get my head round it easily to see if it translates to my case (Template specialization for enum)

Aucun commentaire:

Enregistrer un commentaire