I have used unions earlier comfortably; today I was alarmed when I read this post and came to know that this code
union ARGB { uint32_t colour; str
In C++, Boost Variant implement a safe version of the union, designed to prevent undefined behavior as much as possible.
Its performances are identical to the enum + union construct (stack allocated too etc) but it uses a template list of types instead of the enum :)
enum + union
enum