Comment on Compile-time JSON deserialization in C++Comments−abbeyj2yCould you use something like `template <StringLiteral str> constexpr inline Key<str> key;`? Then you could write `key<"myKey">` instead of `Key<"myKey">{}`, saving you from needing the `{}` each time.−dctwinOP2yOh I think I finally groked what you suggested! Something liketemplate <StringLiteral str> static constexpr Key<str> keyin the class namespace - I think this this would work, but if I understand this correctly, You would need to do likeUser user {...}; user[User::key<"myKey">]Which actually is not so bad...−dctwinOP2yHm - so this would instantiate a variable for each key in the class namespace? I admit I haven't seen anything like this but sounds very interesting
Comments
Could you use something like `template <StringLiteral str> constexpr inline Key<str> key;`? Then you could write `key<"myKey">` instead of `Key<"myKey">{}`, saving you from needing the `{}` each time.
Oh I think I finally groked what you suggested! Something like
template <StringLiteral str> static constexpr Key<str> key
in the class namespace - I think this this would work, but if I understand this correctly, You would need to do like
User user {...}; user[User::key<"myKey">]
Which actually is not so bad...
Hm - so this would instantiate a variable for each key in the class namespace? I admit I haven't seen anything like this but sounds very interesting