3 ms·
Shouldn't it be `max(sizeof(size_t), sizeof(std::string)) + sizeof(discriminant)`? At least in other languages, that's how sum types work
by saghm 9y ago
Shouldn't it be `max(sizeof(size_t), sizeof(std::string)) + sizeof(discriminant)`? At least in other languages, that's how sum types work
- steveklabnik 9y agoI think both of you are also forgetting padding/alignment, though that obviously depends on the exact details.
- jcelerier 9y agofrom what I can see sizeof(std::variant<char, uint8_t>) == 2 so there is no padding between the values and the discriminant
- steveklabnik 9y agoIn this specific case, yes.
- dleslie 9y agoAnd I wasn't clear, in that I was curious about more than the union.
- jcelerier 9y agoyes, forgot the max.