6 ms·
Could you use something like `template <StringLiteral str> constexpr inline Key<str> key;`? Then you could write `key<"myKey">` instead of `Key<"myKey">{}`, sa
by abbeyj 2y ago
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.
- dctwin 2y agoOh 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...
- dctwin 2y agoHm - 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