-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Description
I have to_json() functions defined for classes in the global namespace, and for classes inside my own namespaces. Today I tried to make one for a class defined inside another class. Should that be possible? I'm pretty fuzzy on the details of how ADL works. I tried defining to_json() as a static method in the scope of the outer class, with a second argument of the inner class. I kept getting ‘Static_assert failed "could not find to_json() method in T's namespace" ’ until I moved the inner class (and its to_json()) out into the global namespace. I can live with that, but the inner class is used only within the outer class and seemed like it should be defined there.
class Outer
{
public:
// ...
class Inner
{
// ...
};
static void to_json(nlohmann::json& json_document, const Inner& i)
{
// ...
}
// ...
};
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels