没有运算符"+"与这些操作数匹配
No operator "+" matches these operands
for (TPathInfoList::iterator iter = pathInfoList.begin(); iter != pathInfoList.end(); ++iter)
{
const TPathInfoList::value_type& path = *iter;
EResult resultCode = MakeMSA(path, &msg);
fs::path parentPath = path.parent_path();
std::string shortPath = parentPath.parent_path().filename() + "\" + parentPath.filename() + "\" + path.filename();;
tm t;
time_t timer;
timer = time(NULL);
localtime_s(&t, &timer);
printf("%04d/%02d/%02d %02d:%02d:%02d [%s] %sn",
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
msg.c_str(), shortPath.c_str());
}
我正在尝试提升 1.60,但我坚持这个错误。我做错了什么?
http://prntscr.com/a2yync
错误消息
屏幕截图显示parentPath.parent_path().filename()
不是字符串,而是filesystem::path
。
由于shortPath
是一个string
,我建议parentPath.parent_path().filename().string
:
std::string shortPath = parentPath.parent_path().filename().string()
+ "\" + parentPath.filename().string()
+ "\" + path.filename().string();
或者使shortPath
成为path
并使用与+=
运算符的串联
相关文章:
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- 错误 C2679:二进制"<<":未找到采用类型 'std::string_view' 的右侧操作数的运算符(或者没有可接受的转换)
- 是否所有C++运算符都接受操作数?
- 一元*运算符的操作数是否期望一个 prvalue
- C2678 二进制 '==':未找到采用 'Card' 类型左操作数的运算符(或者没有可接受的转换)
- 我的运算符重载是否有效<<(流插入)左操作数不是 ostream
- 没有运算符"="与这些操作数匹配,JUCE 窗口演示应用程序
- C2679 二进制"<<":未找到采用右操作数类型的运算符
- CPP 运算符重载操作数位置 [] 与 ==
- int* 和 int[] 类型对二进制运算符 + 的操作数无效
- 运算符'<'不能应用于类型 'string' 和 'string' 的操作数
- 错误 C2679 二进制"<<":未找到采用类型为 'T' 的右侧操作数的运算符
- 是否允许三元运算符在C++中计算两个操作数?
- 二进制 '==':未找到采用 'Enemy' 类型左侧操作数的运算符(或者没有可接受的转换)
- 与"运算符>>"不匹配(操作数类型为"QDataStream"和"QJsonObject")
- 类型"int"和"const char [15]"到二进制"运算符<<"的无效操作数^
- 如何摆脱逗号运算符的这个错误右操作数没有效果( wunsued 值)?
- c++ 错误:二进制"运算符+"类型"矩阵*"和"矩阵*"的操作数无效
- c++运算符重载-我实际返回的操作数类型是什么
- 没有运算符>>与这些操作数匹配 ifstream