2 ms·
> can't have any types w/ non-trival copy constructors in a union, though, apparently, which is quite the restriction. That was removed in C++11. The rule now
by jcranmer 4y ago
> can't have any types w/ non-trival copy constructors in a union, though, apparently, which is quite the restriction.
That was removed in C++11. The rule now is:
> Absent default member initializers ([class.mem]), if any non-static data member of a union has a non-trivial default constructor ([class.default.ctor]), copy constructor, move constructor ([class.copy.ctor]), copy assignment operator, move assignment operator ([class.copy.assign]), or destructor ([class.dtor]), the corresponding member function of the union must be user-provided or it will be implicitly deleted ([dcl.fct.def.delete]) for the union.
i.e., you need to provide an explicit version of the special function for the union if any member has a nontrivial implementation.
- dilap 4y agoah, good to know, thanks! unfortunately too late to edit my comment