【发布时间】:2019-07-06 05:10:27
【问题描述】:
我最近将我的 Windows C++ 应用程序转换为 Linux c++ 应用程序,并使用带有 Debian 的 Windows 子系统交叉编译到 Linux。但是,我通过nlohmann使用json库得到以下错误
no match for 'operator-' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}' and 'nlohmann::basic_json<>::value_type {aka nlohmann::basic_json<>}')
我得到这个错误 everywhere 例如,我在 json 元素和 double 之间使用运算符。举个例子:
MSE_total += pow(ref.z[j*multiplier] - actual[j]["z"], 2) / pow(ref.z[j*multiplier], 2);
这是给出上述错误的行。我应该明确说明json中的变量类型吗?我该怎么做?
【问题讨论】:
-
您应该明确说明示例中的类型;)请提供minimal reproducible example
-
actual[j]["z"].get<double>()应该可以解决问题。
标签: c++ linux debian cross-compiling nlohmann-json