-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
Description
I have types in my code that use typedef statements to specialize some of the standard container types. I get a "Multiple declarations" error for to_json when I attempt to convert one of these to json so I can output them into a results file.
Example:
typdef vector<float> State;
typdef vector<float> Offset;and I use it inside of other types like
struct Node {
Offset offset;
State state;
float cost;
}I tried defining a to_json instance for my Node type like so:
void to_json(json& j, const Node& n) {
j = json{{"cost", n.cost}, {"state", n.state}, {"offset", n.offset}};
}but I get an extremely verbose error telling me I have multiple declarations of the to_json instance. It's similar to the error I would get when using the implicit conversion of n.state = j.at("state") without using get<vector<float>>().
I also tried explicitly copying the values to no avail.
void to_json(json& j, const Node& n) {
vector<float> state = n.state;
vector<float> offset = n.offset;
j = json{{"offset", offset}, {"state", n.state}};
}The full error message is really long but I can add it upon request.
Reactions are currently unavailable