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+
If it is absolutely needed to properties be defined in User class maybe you could make use of helper templated constexpr function like:
#include
template
struct Property {
constexpr Property(T Class::* const member) : m_member{ member } {}
T Class::* const m_member;
};
template
constexpr Property get_age_property() {
return Property(&T::age);
}
class User
{
public:
int age;
constexpr static std::tuple> properties = std::make_tuple(
get_age_property()
);
};
int main()
{
}
It seems to compile in webcompiler i.e. VC++ 19.00.23720.0