我有以下枚举并想使用这个枚举的元素创建一个常量映射:
enum UploadFileType {
POPULATION,
PROBABILITY,
REACH,
CMOBILE,
CMOBAPP
}
/**
* Defines which files are uploadable in which country
*/
const map<string,list<UploadFileType>> uploadable_files = {
'hu': [POPULATION, PROBABILITY, REACH, CMOBILE, CMOBAPP],
'sk': [POPULATION, PROBABILITY, REACH]
}
我在这里收到以下错误:
[FAILURE:/home/abc/internal.thrift:29] error: identifier POPULATION is unqualified!
[FAILURE:/home/abc/internal.thrift:29] error: identifier POPULATION is unqualified!
我不知道这应该如何正确显示。
最佳答案
枚举使用点表示法:
const map<string,list<UploadFileType>> uploadable_files = {
'hu': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH, UploadFileType.CMOBILE, UploadFileType.CMOBAPP],
'sk': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH]
}
关于enums - 使用枚举的节俭常量结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22354646/