implementacja is_enum

Próbuję wdrożyćstd::is_enum. Oto mój kod do tej pory:

template<typename T>
struct is_enum {
    static bool value;
};

template<typename T>
bool is_enum<T>::value = false;

template<enum E>
struct is_enum {
    static bool value;
};

template<enum E>
bool is_enum<E>::value = true;

Ten kod powoduje błąd. Dokładniej:

g++ -std=c++0x -Wall -o "enum2" "enum2.cpp" (in directory: /home/aristophanes/Desktop/C++)
Compilation failed.
enum2.cpp:11:15: error: use of enum ‘E’ without previous declaration
enum2.cpp:3:10: error: template parameter ‘class T’
enum2.cpp:12:8: error: redeclared here as ‘int E’
enum2.cpp:16:15: error: use of enum ‘E’ without previous declaration
enum2.cpp:17:14: error: ‘E’ was not declared in this scope
enum2.cpp:17:15: error: template argument 1 is invalid
enum2.cpp:17:18: error: template declaration of ‘bool value’

Czy ktoś może mi wyjaśnić, gdzie popełniam błąd? To moja lub wina kompilatora? Z góry dziękuję.

Edytować: jeśli jest całkowicie błędne, jak mogę to naprawić?

Uwaga: używamg++ -o <file> <file>.cpp

questionAnswers(3)

yourAnswerToTheQuestion