enumeration cannot be a templateis an error that occurs when trying to compile with BCC64 (based on Clang) the following code:
template <typename T> enum class fooEnum : T
{
a,b,c,d,e
};
At first I thought that this explicit prohibition was due to type restrictions enum, if the enum template type can be templated, then this can lead to malformed enums, but when we try this:
template <typename A> struct fooClass
{
enum class fooEnum : A
{
a,b,c,d,e
};
};
It compiles without problems if the type Afollows the same restrictions as the enumerated types listed below, an expression that defines the value of the enumeration:
- Must be an integer constant large enough to match all enumeration values
- Each type listed must be compatible with the integer type
charor signed/ unsigned.
( ), , :
enum class fooEnum : fooClass
{
a,b,c,d,e
};
'fooClass'
, , , . ?
.