我正在尝试创建一个可读函数,它将包含大量重复的 if 语句,使用下面的代码部分。
#define if_identifier(finder, to_find) if((finder = msg.find(to_find)) != std::string npos)
std::string Utility::Decode(const char* buffer, int &playerID) {
std::string msg(buffer);
size_t identifier;
if_identifier(identifier, "P_ID:[") {
}
}
为什么这段代码会导致 type name is not allowed
错误?
最佳答案
因为那里有垃圾 std::string
。
尝试将 std::string npos
更改为 std::string::npos
。
关于c++ - 使用 #define 处理 if 语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32773955/