3 ms·
Yup. I reached the same idea a while ago. I didn't use a hash for the fields though. If you think about it, you don't need a hash function at all. A hash functi
by cbsmith 11y ago
Yup. I reached the same idea a while ago. I didn't use a hash for the fields though. If you think about it, you don't need a hash function at all. A hash function actually slows down compile times! At compile time, you just resolve all the names to offsets in the tuple (simpler, and the added benefit of no hash collisions). I created a "Symbol" type for string constexpr's and used a user defined literal for them.
It seems to me like Boost.Hana is the natural way to do it.
- jbandela1 11y agoLooks very interesting, do you have any examples online?
- daemin 11y agoSo you effectively make an enum out of the names in the tuple. That way you can even use the enum to use as the index into the get<> function calls.
- cbsmith 11y agoYes, that is one way of looking at it, though enums don't use string constants.