私はテンプレートを使用して、単純な型の共用体の構成を簡略化したいと考えています。以下は、実際には「仕事」に見えますが、仕様により、技術的、法的ではありません。 template<typename T> struct union_entry {
void (*destructor_)(void *); // how to destroy type T when active
T
は、私はちょうど++グラムで遊んでた、と私は #include <type_traits>
class Foo {
public: int x;
public: char y;
public: double z;
};
static_assert(std::is_standard_layout<Foo>::value, "Foo is not standard layout");