Closed
Description
I'd like to serialize a vector of glm:vec2;
I have tried to follow the instructions in the readme and implemented from and to json methods like so:
namespace glm {
void to_json(json& j, const glm::vec2& P) {
j = { { "x", P.x }, { "y", P.y } };
};
void from_json(const json& j, glm::vec2& P) {
P.x = j.at("x").get<double>();
P.y = j.at("y").get<double>();
}
}
json j;
std::vector<glm::vec2> points{ glm::vec2( 70, -140 ), glm::vec2(30, -30), glm::vec2(20, 125) };
j["points"] = points;
this little snippet wont compile and I got the following errors:
'glm::begin': ambiguous call to overloaded function
'glm::end': ambiguous call to overloaded function
std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::create': no matching overloaded function found
the funny thing is that when I replace glm::vec2 with a simple Point struct, it compiles, and works as expected.
I'm on windows, using Visual Studio, using the single header from the master branch version3.7.0