I\'m trying to implement a \"property\" system to convert C++ instances into JSON and vice versa. I took a part of the code from Guillaume Racicot\'s answer in this question (C+
My preferred workaround is just to replace the properties
member data with a properties
member function:
class User
{
public:
int age;
constexpr static auto properties() { return std::make_tuple(
Property(&User::age, "age")
); }
};
This works because in the definition of a member function, the class is considered to be completely defined. It also has the desirable attribute that properties
doesn't need to be separately defined if odr-used.