top | item 43793601 (no title) grandempire | 10 months ago That’s for C++. And how is std::variant implemented? discuss order hn newest LowLevelMahn|10 months ago not using a union: https://ojdip.net/2013/10/implementing-a-variant-type-in-cpp... because the union can't be extended with variadic template types LegionMammal978|10 months ago Actually, it does use a union, in both libstdc++ [0] and libc++ [1]. (Underneath a lengthy stack of base classes, since it wouldn't be C++ if it weren't painful to match the specified semantics.)[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3...[1] https://github.com/llvm/llvm-project/blob/llvmorg-20.1.3/lib... grandempire|10 months ago So instead it has a buffer large enough to hold all the types? That’s what union does.Still waiting to hear the security concerns.
LowLevelMahn|10 months ago not using a union: https://ojdip.net/2013/10/implementing-a-variant-type-in-cpp... because the union can't be extended with variadic template types LegionMammal978|10 months ago Actually, it does use a union, in both libstdc++ [0] and libc++ [1]. (Underneath a lengthy stack of base classes, since it wouldn't be C++ if it weren't painful to match the specified semantics.)[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3...[1] https://github.com/llvm/llvm-project/blob/llvmorg-20.1.3/lib... grandempire|10 months ago So instead it has a buffer large enough to hold all the types? That’s what union does.Still waiting to hear the security concerns.
LegionMammal978|10 months ago Actually, it does use a union, in both libstdc++ [0] and libc++ [1]. (Underneath a lengthy stack of base classes, since it wouldn't be C++ if it weren't painful to match the specified semantics.)[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3...[1] https://github.com/llvm/llvm-project/blob/llvmorg-20.1.3/lib...
grandempire|10 months ago So instead it has a buffer large enough to hold all the types? That’s what union does.Still waiting to hear the security concerns.
LowLevelMahn|10 months ago
LegionMammal978|10 months ago
[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3...
[1] https://github.com/llvm/llvm-project/blob/llvmorg-20.1.3/lib...
grandempire|10 months ago
Still waiting to hear the security concerns.