문자열을 열거 형으로 변환해야합니다. 문자열 열거 형 템플릿 오류
나는 String to enum in C++의 아이디어를 따라 그리고 이것은 내 코드입니다 :
#ifndef ENUMPARSER_H
#define ENUMPARSER_H
#include <iostream>
#include <map>
#include <string>
enum MYENUM
{
VAL1,
VAL2
};
using namespace std;
template <typename T>
class EnumParser
{
map<string, T> enumMap;
public:
EnumParser();
T ParseEnum(const string &value)
{
map<string, T>::const_iterator iValue= enumMap.find(value);
if(iValue!=enumMap.end())
return iValue->second;
}
};
EnumParser<MYENUM>::EnumParser()
{
enumMap["VAL1"] = VAL1;
enumMap["VAL2"] = VAL2;
}
#endif // ENUMPARSER_H
나는 다음과 같은 오류를 얻을 컴파일하는 트링 :
내가 QT에서 일하고 있어요 4.8.
내 실수는 무엇입니까?
typename map :: const_iterator iValue = enumMap.find (value); const_iterator는 종속 이름입니다. –
ForEveR