【发布时间】:2014-10-10 10:07:01
【问题描述】:
我正在编写一段应该在多个平台上运行的代码。使用 Visual Studio 2013 编译时我的代码正常工作,但现在我尝试为 Android 编译它,我得到标题中提到的错误。
我要编译的代码是这样的:
#pragma once
#include <string>
class StringUtils
{
public:
static std::string readFile(const std::string& filename);
static std::string& trimStart(std::string& s);
static std::string& trimEnd(std::string& s);
static std::string& trim(std::string& s);
};
错误中提到了上述方法。例如,我尝试像这样调用trim() 方法:
std::string TRData::readValue(std::ifstream& ifs)
{
std::string line;
std::getline(ifs, line);
int colon = line.find_first_of(':');
assert(colon != std::string::npos);
return StringUtils::trim(line.substr(colon + 1));
}
错误信息指向此方法的最后一行。我该如何解决这个问题?正如我所说,它使用 VS2013 编译,但不适用于使用默认 NDK 工具链的 Android。
编辑:忘记粘贴确切的错误信息,这里是:
error : no matching function for call to 'StringUtils::trim(std::basic_string<char>)'
【问题讨论】:
标签: c++