Hi, all
When build code ,got this error: ,bug use g++ -fpermissive test.cpp can build success and work success, how to fix this bug

The follow is my code :
`
#include
#include
#include <nlohmann/json.hpp>
using namespace nlohmann;
int main()
{
constexpr auto jsfile = "/home/parallels/nlohmanntest/sensors.json";
std::ifstream jsonFile(jsfile);
if (!jsonFile.is_open()){
std::cout << "Unable to open json file" << std::endl;
}
auto sensors = json::parse(jsonFile, nullptr, false);
if (sensors.is_discarded()){
std::cout << "Invalid json - parse failed" << std::endl;
}
for (const auto& sensor : sensors){
const json newType = (long int)130;
sensor["sensorType"] = newType;
}
jsonFile.close();
std::ofstream newFile(jsfile, std::ios::trunc | std::ios::out | std::ios::in);
newFile << sensors.dump(4) << std::endl ;
return 0;
}
`
thanks a lot~~
Hi, all
When build code ,got this error: ,bug use
g++ -fpermissive test.cppcan build success and work success, how to fix this bugThe follow is my code :
`
#include
#include
#include <nlohmann/json.hpp>
using namespace nlohmann;
int main()
{
constexpr auto jsfile = "/home/parallels/nlohmanntest/sensors.json";
std::ifstream jsonFile(jsfile);
if (!jsonFile.is_open()){
std::cout << "Unable to open json file" << std::endl;
}
auto sensors = json::parse(jsonFile, nullptr, false);
if (sensors.is_discarded()){
std::cout << "Invalid json - parse failed" << std::endl;
}
}
`
thanks a lot~~