Comment by grandempire
10 months ago
No. This is how sum types are implemented.
And from a runtime perspective it’s going to be a struct with perhaps more padding. You’ll need more details about your specific threat model to explain why that’s bad.
10 months ago
No. This is how sum types are implemented.
And from a runtime perspective it’s going to be a struct with perhaps more padding. You’ll need more details about your specific threat model to explain why that’s bad.
a quick search says that std::variant is the modern replacement to implement your niche feature "sum types"
Not a niche feature. Fundamental for any decent language with a type system.
ok, but C99 and C++11 and others, all have ways to implement types. "Fundemental" as you say.. using UNION in C++ is not a good choice to implement types.. in old C99, you can use UNION that way but why? footguns all around.
1 reply →
Whoa, that's a core building block of programming and computer science that you're dismissing as "niche" without explanation.
yes types are a core building block of programming and computer science, but not using UNION ? this casual dismissal of "criticisms of UNION" here seems superficial and un-wise to me.
1 reply →
That’s for C++. And how is std::variant implemented?
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
2 replies →