https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80187
--- Comment #2 from Tim Shen <timshen at gcc dot gnu.org> --- (In reply to Tim Shen from comment #1) > Assign to myself. > > Implementation idea: > https://godbolt.org/g/ulh4V7 The experiment failed, therefore I posted a patch (see the list) to do the 4-layer inheritance (yikes) hierarchy. The experiment idea was to use CRTP (mixin) bases to dispatch on the triviality, e.g. template<typename... _Types> struct variant : _Variant_storage<_Types...>, _Copy_ctor_mixin<(is_trivially_copy_constructible<_Types> && ...), ... Such that: 1) _Variant_storage holds all memory, and is guaranteed to be trivial on all SMFs. 2) Mixins out-live _Variant_storage, and apply rich SMF semantics, if non-trivial; else forward the triviality. The triviality of variant is decided by the triviality of both the storage. However, the storage is always trivial, so the triviality is controlled by mixins, which is intended. The problem is that once storage is trivial, it has trivial behaviors, e.g. memcpy on copy ctor and copy assign. It's hard to get rid of the memcpys without getting rid of the storage triviality.