It&#x27;s extra work, but you could use std::aligned_union&lt;1, std::string, std::vector&lt;Expression&gt;, ...&gt; to declare space for the union and then use placement new&#x2F;manual destructor calls to initialize and destroy.