gpt4 book ai didi

c++ - 错误 : hash_map does not name a type

转载 作者:太空狗 更新时间:2023-10-29 21:15:32 24 4
gpt4 key购买 nike

我收到一条关于没有命名类型的错误信息,如下:

error: ‘hash_map’ does not name a type
typedef hash_map<const char*,LexUnitX*,MLexUnitFunctions> MLexUnit;

有问题的代码创建了一个自定义 hash_map使用 LexUnitX 类型的结构类型,如下所示:

typedef struct {
int iLexUnit; // lexical unit unique identifier
const char *strLexUnit; // lexical unit as an array of characters (a word, a syllable, etc.)
VLexUnit vLexUnitPronunciations; // alternative pronunciations of the lexical unit
} LexUnitX;

VLexUnit vector 的代码; vector LexUnit类型指针

// lexical unit transcription
typedef struct {
int iLexUnit; // lexical unit id (unique correspondence id <> lexical unit in str format)
int iLexUnitPron; // lexical unit id (unique correspondence id <> lexical unit + pronunciation)
int iIndex; // index of the lexical unit within the lexicon file
vector<int> vPhones; // phonetic transciption
unsigned char iPronunciation; // pronunciation number
unsigned char iType; // standard / filler / sentence delimiter
float fProbability; // pronunciation probability (respect to alternative ones of the same lex unit)
float fInsertionPenalty; // penalty for inserting this lexical unit during decoding
} LexUnit;

class LexiconManager;

typedef vector<LexUnit*> VLexUnit;

最后是 hash_map type 将字符映射到它们相应的数据结构:

// maps lexical units as strings of characters to their corresponding data structure
#if defined __linux__ || defined __APPLE__ || __MINGW32__
typedef std::tr1::unordered_map<const char*,LexUnitX*,MLexUnitFunctions,MLexUnitFunctions> MLexUnit;
#elif _MSC_VER < 1700
typedef hash_map<const char*,LexUnitX*,MLexUnitFunctions> MLexUnit;
#else
#error "unsupported platform"
#endif

我不确定我到底在语法上做错了什么导致了这个错误。

最佳答案

好吧,如果您使用的是提供 hash_map 的标准库实现(这不是标准的一部分),您需要 #include <hash_map>并称之为std::hash_map (根据 this answer,它被 MSVC 和 GNU 放置在 std 命名空间中。)

关于c++ - 错误 : hash_map does not name a type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37470861/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com