我正在尝试编写一个解析config.ini文件的函数,但是我遇到过这个错误,我之前没有遇到过
'std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>> std::make_pair<std::string,std::string>(_Ty1 &&,_Ty2 &&)': cannot convert argument 1 from 'std::string' to 'std::string &&'
我的代码如下所示:
std::map<std::string, std::string> Iasynth::getConfigOptions(std::string const & configData)
{
std::map<std::string, std::string> result;
std::istringstream iss(configData);
bool key = true;
std::string keyData;
std::string valueData;
for (std::string token; std::getline(iss, token, '\n'); )
{
for (std::string token; std::getline(iss, token, '='); )
{
if (key)
{
keyData = std::move(token);
key = false;
}
else
{
valueData = std::move(token);
result.insert(std::make_pair<std::string, std::string>(keyData, valueData));
key = true;
}
}
}
return result;
}