我有一个问题,该问题在XCode中没有浮现(甚至没有警告),但确实允许我在Keil MDK中进行编译。
void grammar::parse(std::string &_expr) {
std::transform(_expr.begin(), _expr.end(), _expr.begin(), std::tolower);
_expr.erase(std::remove_if(_expr.begin(), _expr.end(), std::isspace), _expr.end());
}
那就是我得到的
错误:#304:没有重载函数“std::transform”的实例与参数列表匹配
错误:#304:没有函数模板“std::remove_if”的实例与参数列表匹配
header 包括:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <stdio.h>
#include <algorithm>
您能给我建议去哪里看看吗?我很惊讶XCode版本能按预期运行...
最佳答案
您包括ctype.h
,该 header 在全局 namespace 中声明了一个函数tolower
(这是C库的一部分,因此那里没有其他 namespace )。也许您打算包含cctype
。对于给定的C标准库头X.h
,有一个C++版本cX
在::std
命名空间内提供了一些相同的功能。
关于c++ - KEIL错误: no instance of overloaded function “std::transform” matches the argument list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18371516/