3 ms·
The sizeof(variant) example is wrong. An extra byte is needed to store the discriminator value, which in practice results in 8 extra bytes for these particular
by thrwyexecbrain 5y ago
The sizeof(variant) example is wrong. An extra byte is needed to store the discriminator value, which in practice results in 8 extra bytes for these particular types because of alignment. https://godbolt.org/z/vno3v9rPK https://godbolt.org/z/vno3v9rPK
The tuple drawing is also somewhat misleading, because the first box (int) should be the same size as the second one (double), due to alignment.
- hackingcpp 5y agoYou are right. That was probably dumbed down too much. I'll fix it.